diff options
author | Malte Timmermann <mt@openoffice.org> | 2001-11-12 12:06:40 +0000 |
---|---|---|
committer | Malte Timmermann <mt@openoffice.org> | 2001-11-12 12:06:40 +0000 |
commit | 57ccf3dbed3874f61a3e407ed8f6445484d8eefa (patch) | |
tree | fa6216e61790a6d521bc8f73795683898447c48e /svx/source/editeng/editdoc.cxx | |
parent | #75148# reverted changes (diff) | |
download | core-57ccf3dbed3874f61a3e407ed8f6445484d8eefa.tar.gz core-57ccf3dbed3874f61a3e407ed8f6445484d8eefa.zip |
#94002# Optimized GetAttribs()
Diffstat (limited to 'svx/source/editeng/editdoc.cxx')
-rw-r--r-- | svx/source/editeng/editdoc.cxx | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/svx/source/editeng/editdoc.cxx b/svx/source/editeng/editdoc.cxx index bb8f131cf940..ac191274c211 100644 --- a/svx/source/editeng/editdoc.cxx +++ b/svx/source/editeng/editdoc.cxx @@ -2,9 +2,9 @@ * * $RCSfile: editdoc.cxx,v $ * - * $Revision: 1.20 $ + * $Revision: 1.21 $ * - * last change: $Author: mt $ $Date: 2001-10-11 11:46:59 $ + * last change: $Author: mt $ $Date: 2001-11-12 13:06:40 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -1894,6 +1894,7 @@ void EditDoc::FindAttribs( ContentNode* pNode, USHORT nStartPos, USHORT nEndPos, } } + // ------------------------------------------------------------------------- // class EditCharAttribList // ------------------------------------------------------------------------- @@ -1961,6 +1962,33 @@ void CharAttribList::ResortAttribs() } } +void CharAttribList::OptimizeRanges( SfxItemPool& rItemPool ) +{ + for ( USHORT n = 0; n < aAttribs.Count(); n++ ) + { + EditCharAttrib* pAttr = aAttribs.GetObject( n ); + for ( USHORT nNext = n+1; nNext < aAttribs.Count(); nNext++ ) + { + EditCharAttrib* p = aAttribs.GetObject( nNext ); + if ( ( p->GetStart() == pAttr->GetEnd() ) && ( p->Which() == pAttr->Which() ) ) + { + if ( *p->GetItem() == *pAttr->GetItem() ) + { + pAttr->GetEnd() = p->GetEnd(); + aAttribs.Remove( nNext ); + rItemPool.Remove( *p->GetItem() ); + delete p; + } + break; // only 1 attr with same which can start here. + } + else if ( p->GetStart() > pAttr->GetEnd() ) + { + break; + } + } + } +} + EditCharAttrib* CharAttribList::FindAttrib( USHORT nWhich, USHORT nPos ) { // Rueckwaerts, falls eins dort endet, das naechste startet. |