diff options
author | Noel Grandin <noel@peralex.com> | 2015-08-27 16:38:21 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2015-09-08 11:35:59 +0200 |
commit | 42b0440d55a522806cbb36ea448b61749188ae6b (patch) | |
tree | 98efa3fe9d16c81adf9cf75a72a8d6f47467e76b /sw/source/core/txtnode | |
parent | b359064463fffab69425ad960bbf9f9984b32aaa (diff) |
loplugin:mergeclasses merge SwpHintsArray with SwpHints
and clean up the API a little, there were multiple versions
of the same accessor with different names.
Change-Id: I01e44a7a81c0d67cbb6135a6d196ee106cbf994a
Diffstat (limited to 'sw/source/core/txtnode')
-rw-r--r-- | sw/source/core/txtnode/modeltoviewhelper.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/txtnode/ndhints.cxx | 67 | ||||
-rw-r--r-- | sw/source/core/txtnode/ndtxt.cxx | 44 | ||||
-rw-r--r-- | sw/source/core/txtnode/thints.cxx | 69 | ||||
-rw-r--r-- | sw/source/core/txtnode/txatritr.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/txtnode/txtedt.cxx | 6 |
6 files changed, 93 insertions, 97 deletions
diff --git a/sw/source/core/txtnode/modeltoviewhelper.cxx b/sw/source/core/txtnode/modeltoviewhelper.cxx index 7a8e4fe52581..5d5cd6db54e5 100644 --- a/sw/source/core/txtnode/modeltoviewhelper.cxx +++ b/sw/source/core/txtnode/modeltoviewhelper.cxx @@ -130,7 +130,7 @@ ModelToViewHelper::ModelToViewHelper(const SwTextNode &rNode, ExpandMode eMode) const SwpHints* pSwpHints2 = rNode.GetpSwpHints(); for ( size_t i = 0; pSwpHints2 && i < pSwpHints2->Count(); ++i ) { - const SwTextAttr* pAttr = (*pSwpHints2)[i]; + const SwTextAttr* pAttr = pSwpHints2->Get(i); if (pAttr->HasDummyChar()) { const sal_Int32 nDummyCharPos = pAttr->GetStart(); diff --git a/sw/source/core/txtnode/ndhints.cxx b/sw/source/core/txtnode/ndhints.cxx index 24f52d865039..72c5946d8e77 100644 --- a/sw/source/core/txtnode/ndhints.cxx +++ b/sw/source/core/txtnode/ndhints.cxx @@ -106,38 +106,25 @@ bool CompareSwpHtEnd::operator()(SwTextAttr* const lhs, SwTextAttr* const rhs) c return lcl_IsLessEnd( *lhs, *rhs ); } -void SwpHintsArray::Insert( const SwTextAttr *pHt ) +void SwpHints::Insert( const SwTextAttr *pHt ) { Resort(); - assert(m_HintStarts.find(const_cast<SwTextAttr*>(pHt)) - == m_HintStarts.end()); // "Insert: hint already in HtStart" - assert(m_HintEnds.find(const_cast<SwTextAttr*>(pHt)) - == m_HintEnds.end()); // "Insert: hint already in HtEnd" - m_HintStarts.insert( const_cast<SwTextAttr*>(pHt) ); - m_HintEnds .insert( const_cast<SwTextAttr*>(pHt) ); + assert(m_HintsByStart.find(const_cast<SwTextAttr*>(pHt)) + == m_HintsByStart.end()); // "Insert: hint already in HtStart" + assert(m_HintsByEnd.find(const_cast<SwTextAttr*>(pHt)) + == m_HintsByEnd.end()); // "Insert: hint already in HtEnd" + m_HintsByStart.insert( const_cast<SwTextAttr*>(pHt) ); + m_HintsByEnd .insert( const_cast<SwTextAttr*>(pHt) ); } -void SwpHintsArray::DeleteAtPos( const size_t nPos ) -{ - // optimization: nPos is the position in the Starts array - SwTextAttr *pHt = m_HintStarts[ nPos ]; - m_HintStarts.erase( m_HintStarts.begin() + nPos ); - - Resort(); - - bool const done = m_HintEnds.erase(pHt); - assert(done); - (void) done; // unused in NDEBUG -} - -bool SwpHintsArray::Contains( const SwTextAttr *pHt ) const +bool SwpHints::Contains( const SwTextAttr *pHt ) const { // DO NOT use find() or CHECK here! // if called from SwTextNode::InsertItem, pHt has already been deleted, // so it cannot be dereferenced - for (size_t i = 0; i < m_HintStarts.size(); ++i) + for (size_t i = 0; i < m_HintsByStart.size(); ++i) { - if (m_HintStarts[i] == pHt) + if (m_HintsByStart[i] == pHt) { return true; } @@ -151,14 +138,14 @@ bool SwpHintsArray::Contains( const SwTextAttr *pHt ) const if(!(cond)) \ { \ SAL_WARN("sw.core", text); \ - (const_cast<SwpHintsArray*>(this))->Resort(); \ + (const_cast<SwpHints*>(this))->Resort(); \ return false; \ } -bool SwpHintsArray::Check(bool bPortionsMerged) const +bool SwpHints::Check(bool bPortionsMerged) const { // 1) gleiche Anzahl in beiden Arrays - CHECK_ERR( m_HintStarts.size() == m_HintEnds.size(), + CHECK_ERR( m_HintsByStart.size() == m_HintsByEnd.size(), "HintsCheck: wrong sizes" ); sal_Int32 nLastStart = 0; sal_Int32 nLastEnd = 0; @@ -170,7 +157,7 @@ bool SwpHintsArray::Check(bool bPortionsMerged) const { for (size_t i = 0; i < Count(); ++i) { - SwTextAttr const*const pHint(m_HintStarts[i]); + SwTextAttr const*const pHint(m_HintsByStart[i]); if (RES_TXTATR_AUTOFMT == pHint->Which()) { std::shared_ptr<SfxItemSet> const pSet( @@ -188,7 +175,7 @@ bool SwpHintsArray::Check(bool bPortionsMerged) const // --- Start-Kontrolle --- // 2a) gueltiger Pointer? vgl. DELETEFF - const SwTextAttr *pHt = m_HintStarts[i]; + const SwTextAttr *pHt = m_HintsByStart[i]; CHECK_ERR( 0xFF != *reinterpret_cast<unsigned char const *>(pHt), "HintsCheck: start ptr was deleted" ); // 3a) Stimmt die Start-Sortierung? @@ -205,7 +192,7 @@ bool SwpHintsArray::Check(bool bPortionsMerged) const // --- End-Kontrolle --- // 2b) gueltiger Pointer? vgl. DELETEFF - const SwTextAttr *pHtEnd = m_HintEnds[i]; + const SwTextAttr *pHtEnd = m_HintsByEnd[i]; CHECK_ERR( 0xFF != *reinterpret_cast<unsigned char const *>(pHtEnd), "HintsCheck: end ptr was deleted" ); // 3b) Stimmt die End-Sortierung? @@ -223,13 +210,13 @@ bool SwpHintsArray::Check(bool bPortionsMerged) const // --- Ueberkreuzungen --- // 5) gleiche Pointer in beiden Arrays - if (m_HintStarts.find(const_cast<SwTextAttr*>(pHt)) == m_HintStarts.end()) + if (m_HintsByStart.find(const_cast<SwTextAttr*>(pHt)) == m_HintsByStart.end()) nIdx = COMPLETE_STRING; CHECK_ERR( COMPLETE_STRING != nIdx, "HintsCheck: no GetStartOf" ); // 6) gleiche Pointer in beiden Arrays - if (m_HintEnds.find(const_cast<SwTextAttr*>(pHt)) == m_HintEnds.end()) + if (m_HintsByEnd.find(const_cast<SwTextAttr*>(pHt)) == m_HintsByEnd.end()) nIdx = COMPLETE_STRING; CHECK_ERR( COMPLETE_STRING != nIdx, "HintsCheck: no GetEndOf" ); @@ -245,8 +232,8 @@ bool SwpHintsArray::Check(bool bPortionsMerged) const "HintsCheck: Character attribute in end array" ); // 8) style portion check - const SwTextAttr* pHtThis = m_HintStarts[i]; - const SwTextAttr* pHtLast = i > 0 ? m_HintStarts[i-1] : 0; + const SwTextAttr* pHtThis = m_HintsByStart[i]; + const SwTextAttr* pHtLast = i > 0 ? m_HintsByStart[i-1] : 0; CHECK_ERR( (0 == i) || ( (RES_TXTATR_CHARFMT != pHtLast->Which()) && (RES_TXTATR_AUTOFMT != pHtLast->Which())) @@ -297,7 +284,7 @@ bool SwpHintsArray::Check(bool bPortionsMerged) const bool bFound(false); for (size_t j = i + 1; j < Count(); ++j) { - SwTextAttr *const pOther(m_HintStarts[j]); + SwTextAttr *const pOther(m_HintsByStart[j]); if (pOther->GetStart() > *pHt->End()) { break; // done @@ -343,7 +330,7 @@ bool SwpHintsArray::Check(bool bPortionsMerged) const { for ( size_t j = 0; j < Count(); ++j ) { - SwTextAttr const * const pOther( m_HintStarts[j] ); + SwTextAttr const * const pOther( m_HintsByStart[j] ); if ( pOther->IsNesting() && (i != j) ) { SwComparePosition cmp = ComparePosition( @@ -361,7 +348,7 @@ bool SwpHintsArray::Check(bool bPortionsMerged) const { for ( size_t j = 0; j < i; ++j ) { - SwTextAttr const * const pOther( m_HintStarts[j] ); + SwTextAttr const * const pOther( m_HintsByStart[j] ); if (pOther->HasDummyChar()) { CHECK_ERR( (pOther->GetStart() != pHtThis->GetStart()), @@ -377,13 +364,13 @@ bool SwpHintsArray::Check(bool bPortionsMerged) const // Resort() is called before every Insert and Delete. // Various SwTextNode methods modify hints in a way that violates the -// sort order of the m_HintStarts, m_HintEnds arrays, so this method is needed +// sort order of the m_HintsByStart, m_HintsByEnd arrays, so this method is needed // to restore the order. -void SwpHintsArray::Resort() +void SwpHints::Resort() { - m_HintStarts.Resort(); - m_HintEnds.Resort(); + m_HintsByStart.Resort(); + m_HintsByEnd.Resort(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 331736926478..aa374587d594 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -254,7 +254,7 @@ SwTextNode::~SwTextNode() { // first remove the attribute from the array otherwise // if would delete itself - DestroyAttr( pTmpHints->GetTextHint( --j ) ); + DestroyAttr( pTmpHints->Get( --j ) ); } delete pTmpHints; @@ -311,7 +311,7 @@ static void lcl_ChangeFootnoteRef( SwTextNode &rNode ) SwFootnoteFrm* pFirstFootnoteOfNode = 0; for( size_t j = pSwpHints->Count(); j; ) { - SwTextAttr* pHt = pSwpHints->GetTextHint(--j); + SwTextAttr* pHt = pSwpHints->Get(--j); if (RES_TXTATR_FTN == pHt->Which()) { if( !pFrm ) @@ -464,7 +464,7 @@ SwContentNode *SwTextNode::SplitContentNode( const SwPosition &rPos ) { for ( size_t j = m_pSwpHints->Count(); j; ) { - SwTextAttr* const pHt = m_pSwpHints->GetTextHint( --j ); + SwTextAttr* const pHt = m_pSwpHints->Get( --j ); if ( RES_TXTATR_FLYCNT == pHt ->Which() ) { pHt->GetFlyCnt().GetFrameFormat()->DelFrms(); @@ -552,7 +552,7 @@ SwContentNode *SwTextNode::SplitContentNode( const SwPosition &rPos ) { for ( size_t j = m_pSwpHints->Count(); j; ) { - SwTextAttr* const pHt = m_pSwpHints->GetTextHint( --j ); + SwTextAttr* const pHt = m_pSwpHints->Get( --j ); const sal_Int32* const pEnd = pHt->GetEnd(); if ( pHt->DontExpand() && pEnd && (pHt->GetStart() == *pEnd) ) { @@ -609,7 +609,7 @@ void SwTextNode::MoveTextAttr_To_AttrSet() OSL_ENSURE( m_pSwpHints, "MoveTextAttr_To_AttrSet without SwpHints?" ); for ( size_t i = 0; m_pSwpHints && i < m_pSwpHints->Count(); ++i ) { - SwTextAttr *pHt = m_pSwpHints->GetTextHint(i); + SwTextAttr *pHt = m_pSwpHints->Get(i); if( pHt->GetStart() ) break; @@ -866,7 +866,7 @@ void SwTextNode::Update( { bool bTextAttrChanged = false; bool bStartOfTextAttrChanged = false; - SwTextAttr * const pHint = m_pSwpHints->GetTextHint(n); + SwTextAttr * const pHint = m_pSwpHints->Get(n); sal_Int32 & rStart = pHint->GetStart(); if ( rStart > nChangePos ) { @@ -930,7 +930,7 @@ void SwTextNode::Update( for ( size_t n = 0; n < m_pSwpHints->Count(); ++n ) { bool bTextAttrChanged = false; - SwTextAttr * const pHint = m_pSwpHints->GetTextHint(n); + SwTextAttr * const pHint = m_pSwpHints->Get(n); sal_Int32 & rStart = pHint->GetStart(); sal_Int32 * const pEnd = pHint->GetEnd(); if ( rStart >= nChangePos ) @@ -1244,11 +1244,11 @@ bool SwTextNode::DontExpandFormat( const SwIndex& rIdx, bool bFlag, bool bRet = false; if ( HasHints() ) { - const size_t nEndCnt = m_pSwpHints->GetEndCount(); + const size_t nEndCnt = m_pSwpHints->Count(); size_t nPos = nEndCnt; while( nPos ) { - SwTextAttr *pTmp = m_pSwpHints->GetEnd( --nPos ); + SwTextAttr *pTmp = m_pSwpHints->GetSortedByEnd( --nPos ); sal_Int32 *pEnd = pTmp->GetEnd(); if( !pEnd || *pEnd > nIdx ) continue; @@ -1300,7 +1300,7 @@ lcl_GetTextAttrs( for( size_t i = 0; i < nSize; ++i ) { - SwTextAttr *const pHint = pSwpHints->GetTextHint(i); + SwTextAttr *const pHint = pSwpHints->Get(i); sal_Int32 const nHintStart = pHint->GetStart(); if (nIndex < nHintStart) { @@ -1580,7 +1580,7 @@ void SwTextNode::CopyAttr( SwTextNode *pDest, const sal_Int32 nTextStartIdx, for ( size_t i = 0; i < m_pSwpHints->Count(); ++i ) { - SwTextAttr *const pHt = m_pSwpHints->GetTextHint(i); + SwTextAttr *const pHt = m_pSwpHints->Get(i); sal_Int32 const nAttrStartIdx = pHt->GetStart(); if ( nTextStartIdx < nAttrStartIdx ) break; // ueber das Textende, da nLen == 0 @@ -1764,11 +1764,11 @@ void SwTextNode::CopyText( SwTextNode *const pDest, //Achtung: kann ungueltig sein!! for (size_t n = 0; n < nSize; ++n) { - const sal_Int32 nAttrStartIdx = (*m_pSwpHints)[n]->GetStart(); + const sal_Int32 nAttrStartIdx = m_pSwpHints->Get(n)->GetStart(); if (!( nAttrStartIdx < nEnd)) break; - SwTextAttr * const pHt = m_pSwpHints->GetTextHint(n); + SwTextAttr * const pHt = m_pSwpHints->Get(n); const sal_Int32 * const pEndIdx = pHt->GetEnd(); const sal_uInt16 nWhich = pHt->Which(); @@ -1948,9 +1948,9 @@ OUString SwTextNode::InsertText( const OUString & rStr, const SwIndex & rIdx, { bool bMergePortionsNeeded(false); for ( size_t i = 0; i < m_pSwpHints->Count() && - rIdx >= (*m_pSwpHints)[i]->GetStart(); ++i ) + rIdx >= m_pSwpHints->Get(i)->GetStart(); ++i ) { - SwTextAttr * const pHt = m_pSwpHints->GetTextHint( i ); + SwTextAttr * const pHt = m_pSwpHints->Get( i ); sal_Int32 * const pEndIdx = pHt->GetEnd(); if( !pEndIdx ) continue; @@ -2110,7 +2110,7 @@ void SwTextNode::CutImpl( SwTextNode * const pDest, const SwIndex & rDestStart, size_t nAttrCnt = 0; while (m_pSwpHints && (nAttrCnt < m_pSwpHints->Count())) { - SwTextAttr * const pHt = m_pSwpHints->GetTextHint(nAttrCnt); + SwTextAttr * const pHt = m_pSwpHints->Get(nAttrCnt); const sal_Int32 nAttrStartIdx = pHt->GetStart(); if (!( nAttrStartIdx < nEnd )) break; @@ -2204,7 +2204,7 @@ void SwTextNode::CutImpl( SwTextNode * const pDest, const SwIndex & rDestStart, SwpHts aArr; while (nAttrCnt < m_pSwpHints->Count()) { - SwTextAttr * const pHt = m_pSwpHints->GetTextHint(nAttrCnt); + SwTextAttr * const pHt = m_pSwpHints->Get(nAttrCnt); if (nEnd != pHt->GetStart()) break; const sal_Int32 * const pEndIdx = pHt->GetEnd(); @@ -2266,7 +2266,7 @@ void SwTextNode::EraseText(const SwIndex &rIdx, const sal_Int32 nCount, for ( size_t i = 0; m_pSwpHints && i < m_pSwpHints->Count(); ++i ) { - SwTextAttr *pHt = m_pSwpHints->GetTextHint(i); + SwTextAttr *pHt = m_pSwpHints->Get(i); const sal_Int32 nHintStart = pHt->GetStart(); @@ -2362,7 +2362,7 @@ void SwTextNode::GCAttr() for ( size_t i = 0; m_pSwpHints && i < m_pSwpHints->Count(); ++i ) { - SwTextAttr * const pHt = m_pSwpHints->GetTextHint(i); + SwTextAttr * const pHt = m_pSwpHints->Get(i); // wenn Ende und Start gleich sind --> loeschen const sal_Int32 * const pEndIdx = pHt->GetEnd(); @@ -2653,7 +2653,7 @@ SwTextAttr * SwTextNode::GetTextAttrForCharAt( { for ( size_t i = 0; i < m_pSwpHints->Count(); ++i ) { - SwTextAttr * const pHint = m_pSwpHints->GetTextHint(i); + SwTextAttr * const pHint = m_pSwpHints->Get(i); const sal_Int32 nStartPos = pHint->GetStart(); if ( nIndex < nStartPos ) { @@ -3080,7 +3080,7 @@ bool SwTextNode::GetExpandText( SwTextNode& rDestNd, const SwIndex* pDestIdx, sal_Int32 nInsPos = nDestStt - nIdx; for ( size_t i = 0; i < m_pSwpHints->Count(); ++i ) { - const SwTextAttr* pHt = (*m_pSwpHints)[i]; + const SwTextAttr* pHt = m_pSwpHints->Get(i); const sal_Int32 nAttrStartIdx = pHt->GetStart(); const sal_uInt16 nWhich = pHt->Which(); if (nIdx + nLen <= nAttrStartIdx) @@ -4862,7 +4862,7 @@ void SwTextNode::dumpAsXml(xmlTextWriterPtr pWriter) const xmlTextWriterStartElement(pWriter, BAD_CAST("swpHints")); const SwpHints& rHints = GetSwpHints(); for (size_t i = 0; i < rHints.Count(); ++i) - rHints.GetTextHint(i)->dumpAsXml(pWriter); + rHints.Get(i)->dumpAsXml(pWriter); xmlTextWriterEndElement(pWriter); } diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index 3da268ea6ad6..f13c1d48d80c 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -282,7 +282,7 @@ lcl_DoSplitNew(NestList_t & rSplits, SwTextNode & rNode, */ void SwpHints::InsertNesting(SwTextAttrNesting & rNewHint) { - SwpHintsArray::Insert(& rNewHint); + Insert(& rNewHint); NoteInHistory( & rNewHint, true ); } @@ -375,9 +375,9 @@ SwpHints::TryInsertNesting( SwTextNode & rNode, SwTextAttrNesting & rNewHint ) SplitNew.push_back(& rNewHint); // pass 1: split the inserted hint into fragments if necessary - for ( size_t i = 0; i < GetEndCount(); ++i ) + for ( size_t i = 0; i < Count(); ++i ) { - SwTextAttr * const pOther = GetEnd(i); + SwTextAttr * const pOther = GetSortedByEnd(i); if (pOther->IsNesting()) { @@ -610,7 +610,7 @@ void SwpHints::BuildPortions( SwTextNode& rNode, SwTextAttr& rNewHint, { for ( size_t i = 0; i < Count(); ++i ) { - SwTextAttr* pOther = GetTextHint(i); + SwTextAttr* pOther = Get(i); if ( RES_TXTATR_CHARFMT != pOther->Which() && RES_TXTATR_AUTOFMT != pOther->Which() ) @@ -661,7 +661,7 @@ void SwpHints::BuildPortions( SwTextNode& rNode, SwTextAttr& rNewHint, // Insert the newly created attributes: for ( aIter = aInsDelHints.begin(); aIter != aInsDelHints.end(); ++aIter ) { - SwpHintsArray::Insert( *aIter ); + Insert( *aIter ); NoteInHistory( *aIter, true ); } } @@ -681,7 +681,7 @@ void SwpHints::BuildPortions( SwTextNode& rNode, SwTextAttr& rNewHint, { for ( size_t i = 0; i < Count(); ++i ) { - const SwTextAttr* pOther = GetTextHint(i); + const SwTextAttr* pOther = Get(i); if ( RES_TXTATR_CHARFMT != pOther->Which() && RES_TXTATR_AUTOFMT != pOther->Which() ) @@ -713,7 +713,7 @@ void SwpHints::BuildPortions( SwTextNode& rNode, SwTextAttr& rNewHint, // Get all hints that are in [nPorStart, nPorEnd[: for ( size_t i = 0; i < Count(); ++i ) { - SwTextAttr *pOther = GetTextHint(i); + SwTextAttr *pOther = Get(i); if ( RES_TXTATR_CHARFMT != pOther->Which() && RES_TXTATR_AUTOFMT != pOther->Which() ) @@ -798,7 +798,7 @@ void SwpHints::BuildPortions( SwTextNode& rNode, SwTextAttr& rNewHint, { pNewAttr = MakeTextAttr( *rNode.GetDoc(), aNewSet, nPorStart, nPorEnd ); - SwpHintsArray::Insert( pNewAttr ); + Insert( pNewAttr ); NoteInHistory( pNewAttr, true ); } } @@ -940,7 +940,7 @@ void SwpHints::BuildPortions( SwTextNode& rNode, SwTextAttr& rNewHint, if ( pNewAttr ) { - SwpHintsArray::Insert( pNewAttr ); + Insert( pNewAttr ); // if ( bDestroyHint ) NoteInHistory( pNewAttr, true ); } @@ -1694,7 +1694,7 @@ void SwTextNode::DeleteAttributes( for ( size_t nPos = 0; m_pSwpHints && nPos < m_pSwpHints->Count(); ++nPos ) { - SwTextAttr * const pTextHt = m_pSwpHints->GetTextHint( nPos ); + SwTextAttr * const pTextHt = m_pSwpHints->Get( nPos ); const sal_Int32 nHintStart = pTextHt->GetStart(); if (nStart < nHintStart) { @@ -1874,7 +1874,7 @@ bool SwTextNode::SetAttr( { for ( size_t n = 0; n < m_pSwpHints->Count(); ++n ) { - if ( (*m_pSwpHints)[ n ]->IsCharFormatAttr() ) + if ( m_pSwpHints->Get( n )->IsCharFormatAttr() ) { bHasCharFormats = true; break; @@ -2109,7 +2109,7 @@ bool SwTextNode::GetAttr( SfxItemSet& rSet, sal_Int32 nStt, sal_Int32 nEnd, { for (size_t n = 0; n < nSize; ++n) { - const SwTextAttr* pHt = (*m_pSwpHints)[n]; + const SwTextAttr* pHt = m_pSwpHints->Get(n); const sal_Int32 nAttrStart = pHt->GetStart(); if( nAttrStart > nEnd ) // ueber den Bereich hinaus break; @@ -2135,7 +2135,7 @@ bool SwTextNode::GetAttr( SfxItemSet& rSet, sal_Int32 nStt, sal_Int32 nEnd, for (size_t n = 0; n < nSize; ++n) { - const SwTextAttr* pHt = (*m_pSwpHints)[n]; + const SwTextAttr* pHt = m_pSwpHints->Get(n); const sal_Int32 nAttrStart = pHt->GetStart(); if( nAttrStart > nEnd ) // ueber den Bereich hinaus break; @@ -2359,7 +2359,7 @@ lcl_CollectHintSpans(const SwpHints& i_rHints, const sal_Int32 nLength, for (size_t i = 0; i < i_rHints.Count(); ++i) { - const SwTextAttr* const pHint(i_rHints[i]); + const SwTextAttr* pHint = i_rHints.Get(i); const sal_uInt16 nWhich(pHint->Which()); if (nWhich == RES_TXTATR_CHARFMT || nWhich == RES_TXTATR_AUTOFMT) { @@ -2580,7 +2580,7 @@ void SwpHints::CalcFlags() const size_t nSize = Count(); for( size_t nPos = 0; nPos < nSize; ++nPos ) { - const SwTextAttr* pAttr = (*this)[ nPos ]; + const SwTextAttr* pAttr = Get( nPos ); switch( pAttr->Which() ) { case RES_TXTATR_FTN: @@ -2613,7 +2613,7 @@ bool SwpHints::CalcHiddenParaField() for( size_t nPos = 0; nPos < nSize; ++nPos ) { - pTextHt = (*this)[ nPos ]; + pTextHt = Get(nPos); const sal_uInt16 nWhich = pTextHt->Which(); if( RES_TXTATR_FIELD == nWhich ) @@ -2648,7 +2648,7 @@ bool SwpHints::MergePortions( SwTextNode& rNode ) return false; // sort before merging - SwpHintsArray::Resort(); + Resort(); bool bRet = false; typedef std::multimap< int, std::pair<SwTextAttr*, bool> > PortionMap; @@ -2660,7 +2660,7 @@ bool SwpHints::MergePortions( SwTextNode& rNode ) // get portions by start position: for ( size_t i = 0; i < Count(); ++i ) { - SwTextAttr *pHt = GetTextHint( i ); + SwTextAttr *pHt = Get( i ); if ( RES_TXTATR_CHARFMT != pHt->Which() && RES_TXTATR_AUTOFMT != pHt->Which() ) //&& @@ -2679,7 +2679,7 @@ bool SwpHints::MergePortions( SwTextNode& rNode ) // could be produced by ReplaceText or (maybe?) RstAttr if (pHt->GetStart() == *pHt->GetEnd()) { - SwpHintsArray::DeleteAtPos(i); // kill it without History! + DeleteAtPos(i); // kill it without History! SwTextAttr::Destroy(pHt, rNode.GetDoc()->GetAttrPool()); --i; continue; @@ -2871,7 +2871,7 @@ bool SwpHints::MergePortions( SwTextNode& rNode ) if (bRet) { - SwpHintsArray::Resort(); + Resort(); } } else @@ -2922,7 +2922,7 @@ static void lcl_CheckSortNumber( const SwpHints& rHints, SwTextCharFormat& rNewC for ( size_t i = 0; i < rHints.Count(); ++i ) { - const SwTextAttr* pOtherHt = rHints[i]; + const SwTextAttr* pOtherHt = rHints.Get(i); const sal_Int32 nOtherStart = pOtherHt->GetStart(); @@ -3115,7 +3115,7 @@ bool SwpHints::TryInsertHint( sal_Int32 *pTmpHintEnd; for( size_t n = 0, nEnd = Count(); n < nEnd; ++n ) { - if (RES_TXTATR_REFMARK == (pTmpHt = GetTextHint(n))->Which() && + if (RES_TXTATR_REFMARK == (pTmpHt = Get(n))->Which() && pHint->GetAttr() == pTmpHt->GetAttr() && 0 != ( pTmpHtEnd = pTmpHt->GetEnd() ) && 0 != ( pTmpHintEnd = pHint->GetEnd() ) ) @@ -3181,7 +3181,7 @@ bool SwpHints::TryInsertHint( sal_Int32 nHtStart = pHint->GetStart(); if( !pHtEnd ) { - SwpHintsArray::Insert( pHint ); + Insert( pHint ); CalcFlags(); #ifdef DBG_UTIL if( !rNode.GetDoc()->IsInReading() ) @@ -3266,7 +3266,7 @@ bool SwpHints::TryInsertHint( if ( RES_TXTATR_CHARFMT == nWhich ) lcl_CheckSortNumber(*this, *static_txtattr_cast<SwTextCharFormat*>(pHint)); - SwpHintsArray::Insert( pHint ); + Insert( pHint ); NoteInHistory( pHint, true ); } } @@ -3292,10 +3292,19 @@ bool SwpHints::TryInsertHint( void SwpHints::DeleteAtPos( const size_t nPos ) { - SwTextAttr *pHint = GetTextHint(nPos); + SwTextAttr *pHint = Get(nPos); // ChainDelete( pHint ); NoteInHistory( pHint ); - SwpHintsArray::DeleteAtPos( nPos ); + + // optimization: nPos is the position in the Starts array + SwTextAttr *pHt = m_HintsByStart[ nPos ]; + m_HintsByStart.erase( m_HintsByStart.begin() + nPos ); + + Resort(); + + bool const done = m_HintsByEnd.erase(pHt); + assert(done); + (void) done; // unused in NDEBUG if( pHint->Which() == RES_TXTATR_FIELD ) { @@ -3331,7 +3340,7 @@ void SwpHints::DeleteAtPos( const size_t nPos ) void SwpHints::Delete( SwTextAttr* pTextHt ) { // Attr 2.0: SwpHintsArr::Delete( pTextHt ); - const size_t nPos = GetStartOf( pTextHt ); + const size_t nPos = GetIndexOf( pTextHt ); OSL_ENSURE( SAL_MAX_SIZE != nPos, "Attribut nicht im Attribut-Array!" ); if( SAL_MAX_SIZE != nPos ) DeleteAtPos( nPos ); @@ -3344,7 +3353,7 @@ void SwTextNode::ClearSwpHintsArr( bool bDelFields ) size_t nPos = 0; while ( nPos < m_pSwpHints->Count() ) { - SwTextAttr* pDel = m_pSwpHints->GetTextHint( nPos ); + SwTextAttr* pDel = m_pSwpHints->Get( nPos ); bool bDel = false; switch( pDel->Which() ) @@ -3365,7 +3374,7 @@ void SwTextNode::ClearSwpHintsArr( bool bDelFields ) if( bDel ) { - m_pSwpHints->SwpHintsArray::DeleteAtPos( nPos ); + m_pSwpHints->DeleteAtPos( nPos ); DestroyAttr( pDel ); } else @@ -3394,7 +3403,7 @@ sal_uInt16 SwTextNode::GetLang( const sal_Int32 nBegin, const sal_Int32 nLen, for ( size_t i = 0; i < nSize; ++i ) { // ist der Attribut-Anfang schon groesser als der Idx ? - const SwTextAttr *pHt = m_pSwpHints->operator[](i); + const SwTextAttr *pHt = m_pSwpHints->Get(i); const sal_Int32 nAttrStart = pHt->GetStart(); if( nEnd < nAttrStart ) break; diff --git a/sw/source/core/txtnode/txatritr.cxx b/sw/source/core/txtnode/txatritr.cxx index c9f7158ffe4a..37d413393811 100644 --- a/sw/source/core/txtnode/txatritr.cxx +++ b/sw/source/core/txtnode/txatritr.cxx @@ -202,7 +202,7 @@ void SwTextAttrIterator::SearchNextChg() const SfxPoolItem* pItem = 0; for( ; nAttrPos < pHts->Count(); ++nAttrPos ) { - const SwTextAttr* pHt = (*pHts)[ nAttrPos ]; + const SwTextAttr* pHt = pHts->Get( nAttrPos ); const sal_Int32* pEnd = pHt->End(); const sal_Int32 nHtStt = pHt->GetStart(); if( nHtStt < nStt && ( !pEnd || *pEnd <= nStt )) diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx index ac22a84c1025..582c60f189a6 100644 --- a/sw/source/core/txtnode/txtedt.cxx +++ b/sw/source/core/txtnode/txtedt.cxx @@ -421,10 +421,10 @@ void SwTextNode::RstTextAttr( sal_Int32 nAttrStart; SwTextAttr *pHt = NULL; while ( (i < m_pSwpHints->Count()) - && ( ( ( nAttrStart = (*m_pSwpHints)[i]->GetStart()) < nEnd ) + && ( ( ( nAttrStart = m_pSwpHints->Get(i)->GetStart()) < nEnd ) || nLen==0 ) && !bExactRange) { - pHt = m_pSwpHints->GetTextHint(i); + pHt = m_pSwpHints->Get(i); // attributes without end stay in! // but consider <bInclRefToxMark> used by Undo @@ -605,7 +605,7 @@ void SwTextNode::RstTextAttr( // Only delete the hints which start at nStt and end at nEnd. for (i = 0; i < m_pSwpHints->Count(); ++i) { - SwTextAttr* pHint = m_pSwpHints->GetTextHint(i); + SwTextAttr* pHint = m_pSwpHints->Get(i); if (pHint->GetStart() != nStt) continue; |