diff options
author | Ivo Hinkelmann <ihi@openoffice.org> | 2006-11-14 14:57:39 +0000 |
---|---|---|
committer | Ivo Hinkelmann <ihi@openoffice.org> | 2006-11-14 14:57:39 +0000 |
commit | 8c5563ea152056cd822ec1601441cd0ebfbddb83 (patch) | |
tree | a76e6ba7a9dda59ffa4f0c7d692e6e34f00c24ad /sc | |
parent | 9930dcf9aa5220b3faf4da5399af1a127c1fa84d (diff) |
INTEGRATION: CWS aw024 (1.2.350); FILE MERGED
2006/08/03 19:30:00 aw 1.2.350.3: RESYNC: (1.3-1.4); FILE MERGED
2005/09/20 03:47:59 aw 1.2.350.2: RESYNC: (1.2-1.3); FILE MERGED
2005/07/29 17:44:35 nn 1.2.350.1: #114409# use OverlayObjectCell for cell cursor, selection and AutoFill handle
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/view/invmerge.cxx | 63 |
1 files changed, 59 insertions, 4 deletions
diff --git a/sc/source/ui/view/invmerge.cxx b/sc/source/ui/view/invmerge.cxx index 10c1d9d99f15..20657a1c9f9c 100644 --- a/sc/source/ui/view/invmerge.cxx +++ b/sc/source/ui/view/invmerge.cxx @@ -4,9 +4,9 @@ * * $RCSfile: invmerge.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: kz $ $Date: 2006-07-21 15:02:25 $ + * last change: $Author: ihi $ $Date: 2006-11-14 15:57:39 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -46,11 +46,19 @@ //------------------------------------------------------------------ ScInvertMerger::ScInvertMerger( Window* pWindow ) : - pWin( pWindow ) + pWin( pWindow ), + pRects( NULL ) { // both rectangles empty } +ScInvertMerger::ScInvertMerger( ::std::vector< Rectangle >* pRectangles ) : + pWin( NULL ), + pRects( pRectangles ) +{ + // collect rectangles instead of inverting +} + ScInvertMerger::~ScInvertMerger() { Flush(); @@ -62,6 +70,49 @@ void ScInvertMerger::Flush() FlushTotal(); DBG_ASSERT( aLineRect.IsEmpty() && aTotalRect.IsEmpty(), "Flush: not empty" ); + + if ( pRects ) + { + // + // also join vertically if there are non-adjacent columns involved + // + + size_t nComparePos = 0; + while ( nComparePos < pRects->size() ) + { + Rectangle aCompRect = (*pRects)[nComparePos]; + sal_Int32 nBottom = aCompRect.Bottom(); + size_t nOtherPos = nComparePos + 1; + + while ( nOtherPos < pRects->size() ) + { + Rectangle aOtherRect = (*pRects)[nOtherPos]; + if ( aOtherRect.Top() > nBottom + 1 ) + { + // rectangles are sorted, so we can stop searching + break; + } + if ( aOtherRect.Top() == nBottom + 1 && + aOtherRect.Left() == aCompRect.Left() && + aOtherRect.Right() == aCompRect.Right() ) + { + // extend first rectangle + nBottom = aOtherRect.Bottom(); + aCompRect.Bottom() = nBottom; + (*pRects)[nComparePos].Bottom() = nBottom; + + // remove second rectangle + pRects->erase( pRects->begin() + nOtherPos ); + + // continue at unmodified nOtherPos + } + else + ++nOtherPos; + } + + ++nComparePos; + } + } } void ScInvertMerger::FlushTotal() @@ -69,7 +120,11 @@ void ScInvertMerger::FlushTotal() if( aTotalRect.IsEmpty() ) return; // nothing to do - pWin->Invert( aTotalRect, INVERT_HIGHLIGHT ); + if ( pWin ) + pWin->Invert( aTotalRect, INVERT_HIGHLIGHT ); + else if ( pRects ) + pRects->push_back( aTotalRect ); + aTotalRect.SetEmpty(); } |