summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornpcdoom <venccsralph@gmail.com>2011-02-21 10:56:28 -0800
committerJoseph Powers <jpowers27@cox.net>2011-02-21 10:56:28 -0800
commit0f8cdfc15c2af06775270d50edec47515ff74b2f (patch)
tree39aa95b62f5579cd9253ec9bdb45748730b65c89
parentc87147cb0b1638d86ace10b42a953f004b1076de (diff)
[PATCH 04/10] Removed deprecated List container.
-rw-r--r--sc/source/ui/inc/prevloc.hxx10
-rw-r--r--sc/source/ui/view/prevloc.cxx233
2 files changed, 120 insertions, 123 deletions
diff --git a/sc/source/ui/inc/prevloc.hxx b/sc/source/ui/inc/prevloc.hxx
index fdba3a6f66ab..b706bdc6ca09 100644
--- a/sc/source/ui/inc/prevloc.hxx
+++ b/sc/source/ui/inc/prevloc.hxx
@@ -29,11 +29,12 @@
#ifndef SC_PREVLOC_HXX
#define SC_PREVLOC_HXX
-#include "address.hxx"
-#include <tools/list.hxx>
-#include <vcl/mapmod.hxx>
+#include <boost/ptr_container/ptr_list.hpp>
+
#include <sal/types.h>
+#include <vcl/mapmod.hxx>
+#include "address.hxx"
#define SC_PREVIEW_MAXRANGES 4
#define SC_PREVIEW_RANGE_EDGE 0
@@ -48,6 +49,7 @@ class Rectangle;
class ScAddress;
class ScRange;
class ScDocument;
+class ScPreviewLocationEntry;
struct ScPreviewColRowInfo
{
@@ -100,7 +102,7 @@ class ScPreviewLocationData
sal_uInt8 aDrawRangeId[SC_PREVIEW_MAXRANGES];
USHORT nDrawRanges;
SCTAB nPrintTab;
- List aEntries;
+ boost::ptr_list<ScPreviewLocationEntry> aEntries;
Rectangle GetOffsetPixel( const ScAddress& rCellPos, const ScRange& rRange ) const;
diff --git a/sc/source/ui/view/prevloc.cxx b/sc/source/ui/view/prevloc.cxx
index 22e24170fba0..f0c93d563bdb 100644
--- a/sc/source/ui/view/prevloc.cxx
+++ b/sc/source/ui/view/prevloc.cxx
@@ -29,18 +29,12 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sc.hxx"
-
-
-// INCLUDE ---------------------------------------------------------------
-
-#include <vcl/outdev.hxx>
#include <tools/debug.hxx>
+#include <vcl/outdev.hxx>
#include "prevloc.hxx"
#include "document.hxx"
-//==================================================================
-
enum ScPreviewLocationType
{
SC_PLOC_CELLRANGE,
@@ -73,8 +67,6 @@ struct ScPreviewLocationEntry
}
};
-//==================================================================
-
ScPreviewTableInfo::ScPreviewTableInfo() :
nTab(0),
nCols(0),
@@ -166,8 +158,6 @@ void ScPreviewTableInfo::LimitToArea( const Rectangle& rPixelArea )
}
}
-//------------------------------------------------------------------
-
ScPreviewLocationData::ScPreviewLocationData( ScDocument* pDocument, OutputDevice* pWin ) :
pWindow( pWin ),
pDoc( pDocument ),
@@ -193,13 +183,7 @@ void ScPreviewLocationData::SetPrintTab( SCTAB nNew )
void ScPreviewLocationData::Clear()
{
- void* pEntry = aEntries.First();
- while ( pEntry )
- {
- delete (ScPreviewLocationEntry*) pEntry;
- pEntry = aEntries.Next();
- }
- aEntries.Clear();
+ aEntries.clear();
nDrawRanges = 0;
}
@@ -208,23 +192,30 @@ void ScPreviewLocationData::AddCellRange( const Rectangle& rRect, const ScRange&
const MapMode& rDrawMap )
{
Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
- aEntries.Insert( new ScPreviewLocationEntry( SC_PLOC_CELLRANGE, aPixelRect, rRange, bRepCol, bRepRow ) );
+ aEntries.push_front( new ScPreviewLocationEntry( SC_PLOC_CELLRANGE, aPixelRect, rRange, bRepCol, bRepRow ) );
DBG_ASSERT( nDrawRanges < SC_PREVIEW_MAXRANGES, "too many ranges" );
+
if ( nDrawRanges < SC_PREVIEW_MAXRANGES )
{
aDrawRectangle[nDrawRanges] = aPixelRect;
aDrawMapMode[nDrawRanges] = rDrawMap;
- if (bRepCol)
- if (bRepRow)
- aDrawRangeId[nDrawRanges] = SC_PREVIEW_RANGE_EDGE;
- else
- aDrawRangeId[nDrawRanges] = SC_PREVIEW_RANGE_REPCOL;
+
+ if (bRepCol)
+ {
+ if (bRepRow)
+ aDrawRangeId[nDrawRanges] = SC_PREVIEW_RANGE_EDGE;
else
- if (bRepRow)
- aDrawRangeId[nDrawRanges] = SC_PREVIEW_RANGE_REPROW;
- else
- aDrawRangeId[nDrawRanges] = SC_PREVIEW_RANGE_TAB;
+ aDrawRangeId[nDrawRanges] = SC_PREVIEW_RANGE_REPCOL;
+ }
+ else
+ {
+ if (bRepRow)
+ aDrawRangeId[nDrawRanges] = SC_PREVIEW_RANGE_REPROW;
+ else
+ aDrawRangeId[nDrawRanges] = SC_PREVIEW_RANGE_TAB;
+ }
+
++nDrawRanges;
}
}
@@ -234,7 +225,8 @@ void ScPreviewLocationData::AddColHeaders( const Rectangle& rRect, SCCOL nStartC
SCTAB nTab = 0; //! ?
ScRange aRange( nStartCol, 0, nTab, nEndCol, 0, nTab );
Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
- aEntries.Insert( new ScPreviewLocationEntry( SC_PLOC_COLHEADER, aPixelRect, aRange, bRepCol, FALSE ) );
+
+ aEntries.push_front( new ScPreviewLocationEntry( SC_PLOC_COLHEADER, aPixelRect, aRange, bRepCol, FALSE ) );
}
void ScPreviewLocationData::AddRowHeaders( const Rectangle& rRect, SCROW nStartRow, SCROW nEndRow, BOOL bRepRow )
@@ -242,7 +234,8 @@ void ScPreviewLocationData::AddRowHeaders( const Rectangle& rRect, SCROW nStartR
SCTAB nTab = 0; //! ?
ScRange aRange( 0, nStartRow, nTab, 0, nEndRow, nTab );
Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
- aEntries.Insert( new ScPreviewLocationEntry( SC_PLOC_ROWHEADER, aPixelRect, aRange, FALSE, bRepRow ) );
+
+ aEntries.push_front( new ScPreviewLocationEntry( SC_PLOC_ROWHEADER, aPixelRect, aRange, FALSE, bRepRow ) );
}
void ScPreviewLocationData::AddHeaderFooter( const Rectangle& rRect, BOOL bHeader, BOOL bLeft )
@@ -253,24 +246,25 @@ void ScPreviewLocationData::AddHeaderFooter( const Rectangle& rRect, BOOL bHeade
ScPreviewLocationType eType = bHeader ?
( bLeft ? SC_PLOC_LEFTHEADER : SC_PLOC_RIGHTHEADER ) :
( bLeft ? SC_PLOC_LEFTFOOTER : SC_PLOC_RIGHTFOOTER );
- aEntries.Insert( new ScPreviewLocationEntry( eType, aPixelRect, aRange, FALSE, FALSE ) );
+
+ aEntries.push_front( new ScPreviewLocationEntry( eType, aPixelRect, aRange, FALSE, FALSE ) );
}
void ScPreviewLocationData::AddNoteMark( const Rectangle& rRect, const ScAddress& rPos )
{
ScRange aRange( rPos );
Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
- aEntries.Insert( new ScPreviewLocationEntry( SC_PLOC_NOTEMARK, aPixelRect, aRange, FALSE, FALSE ) );
+
+ aEntries.push_front( new ScPreviewLocationEntry( SC_PLOC_NOTEMARK, aPixelRect, aRange, FALSE, FALSE ) );
}
void ScPreviewLocationData::AddNoteText( const Rectangle& rRect, const ScAddress& rPos )
{
ScRange aRange( rPos );
Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
- aEntries.Insert( new ScPreviewLocationEntry( SC_PLOC_NOTETEXT, aPixelRect, aRange, FALSE, FALSE ) );
-}
-//------------------------------------------------------------------
+ aEntries.push_front( new ScPreviewLocationEntry( SC_PLOC_NOTETEXT, aPixelRect, aRange, FALSE, FALSE ) );
+}
void ScPreviewLocationData::GetDrawRange( USHORT nPos, Rectangle& rPixelRect, MapMode& rMapMode, sal_uInt8& rRangeId ) const
{
@@ -283,15 +277,16 @@ void ScPreviewLocationData::GetDrawRange( USHORT nPos, Rectangle& rPixelRect, Ma
}
}
-ScPreviewLocationEntry* lcl_GetEntryByAddress( const List& rEntries, const ScAddress& rPos, ScPreviewLocationType eType )
+ScPreviewLocationEntry* lcl_GetEntryByAddress( const boost::ptr_list<ScPreviewLocationEntry> &rEntries,
+ const ScAddress& rPos, ScPreviewLocationType eType )
{
- ULONG nCount = rEntries.Count();
- for (ULONG nListPos=0; nListPos<nCount; nListPos++)
+ boost::ptr_list<ScPreviewLocationEntry>::const_iterator it;
+ for (it = rEntries.begin(); it != rEntries.end(); ++it)
{
- ScPreviewLocationEntry* pEntry = (ScPreviewLocationEntry*)rEntries.GetObject(nListPos);
- if ( pEntry->eType == eType && pEntry->aCellRange.In( rPos ) )
- return pEntry;
+ if ( it->eType == eType && it->aCellRange.In( rPos ) )
+ return const_cast<ScPreviewLocationEntry*>(&(*it));
}
+
return NULL;
}
@@ -342,73 +337,74 @@ BOOL ScPreviewLocationData::GetCellPosition( const ScAddress& rCellPos, Rectangl
BOOL ScPreviewLocationData::HasCellsInRange( const Rectangle& rVisiblePixel ) const
{
- ULONG nCount = aEntries.Count();
- for (ULONG nListPos=0; nListPos<nCount; nListPos++)
+ boost::ptr_list<ScPreviewLocationEntry>::const_iterator it;
+ for (it = aEntries.begin(); it != aEntries.end(); ++it)
{
- ScPreviewLocationEntry* pEntry = (ScPreviewLocationEntry*)aEntries.GetObject(nListPos);
- ScPreviewLocationType eType = pEntry->eType;
- if ( eType == SC_PLOC_CELLRANGE || eType == SC_PLOC_COLHEADER || eType == SC_PLOC_ROWHEADER )
- if ( pEntry->aPixelRect.IsOver( rVisiblePixel ) )
+ if ( it->eType == SC_PLOC_CELLRANGE || it->eType == SC_PLOC_COLHEADER || it->eType == SC_PLOC_ROWHEADER )
+ if ( it->aPixelRect.IsOver( rVisiblePixel ) )
return TRUE;
}
+
return FALSE;
}
BOOL ScPreviewLocationData::GetHeaderPosition( Rectangle& rRect ) const
{
- ULONG nCount = aEntries.Count();
- for (ULONG nListPos=0; nListPos<nCount; nListPos++)
+ boost::ptr_list<ScPreviewLocationEntry>::const_iterator it;
+ for (it = aEntries.begin(); it != aEntries.end(); ++it)
{
- ScPreviewLocationEntry* pEntry = (ScPreviewLocationEntry*)aEntries.GetObject(nListPos);
- if ( pEntry->eType == SC_PLOC_LEFTHEADER || pEntry->eType == SC_PLOC_RIGHTHEADER )
+ if ( it->eType == SC_PLOC_LEFTHEADER || it->eType == SC_PLOC_RIGHTHEADER )
{
- rRect = pEntry->aPixelRect;
+ rRect = it->aPixelRect;
return TRUE;
}
}
+
return FALSE;
}
BOOL ScPreviewLocationData::GetFooterPosition( Rectangle& rRect ) const
{
- ULONG nCount = aEntries.Count();
- for (ULONG nListPos=0; nListPos<nCount; nListPos++)
+ boost::ptr_list<ScPreviewLocationEntry>::const_iterator it;
+ for (it = aEntries.begin(); it != aEntries.end(); ++it)
{
- ScPreviewLocationEntry* pEntry = (ScPreviewLocationEntry*)aEntries.GetObject(nListPos);
- if ( pEntry->eType == SC_PLOC_LEFTFOOTER || pEntry->eType == SC_PLOC_RIGHTFOOTER )
+ if ( it->eType == SC_PLOC_LEFTFOOTER || it->eType == SC_PLOC_RIGHTFOOTER )
{
- rRect = pEntry->aPixelRect;
+ rRect = it->aPixelRect;
return TRUE;
}
}
+
return FALSE;
}
BOOL ScPreviewLocationData::IsHeaderLeft() const
{
- ULONG nCount = aEntries.Count();
- for (ULONG nListPos=0; nListPos<nCount; nListPos++)
+ boost::ptr_list<ScPreviewLocationEntry>::const_iterator it;
+ for (it = aEntries.begin(); it != aEntries.end(); ++it)
{
- ScPreviewLocationEntry* pEntry = (ScPreviewLocationEntry*)aEntries.GetObject(nListPos);
- if ( pEntry->eType == SC_PLOC_LEFTHEADER )
+ if ( it->eType == SC_PLOC_LEFTHEADER )
return TRUE;
- if ( pEntry->eType == SC_PLOC_RIGHTHEADER )
+
+ if ( it->eType == SC_PLOC_RIGHTHEADER )
return FALSE;
}
+
return FALSE;
}
BOOL ScPreviewLocationData::IsFooterLeft() const
{
- ULONG nCount = aEntries.Count();
- for (ULONG nListPos=0; nListPos<nCount; nListPos++)
+ boost::ptr_list<ScPreviewLocationEntry>::const_iterator it;
+ for (it = aEntries.begin(); it != aEntries.end(); ++it)
{
- ScPreviewLocationEntry* pEntry = (ScPreviewLocationEntry*)aEntries.GetObject(nListPos);
- if ( pEntry->eType == SC_PLOC_LEFTFOOTER )
+ if ( it->eType == SC_PLOC_LEFTFOOTER )
return TRUE;
- if ( pEntry->eType == SC_PLOC_RIGHTFOOTER )
+
+ if ( it->eType == SC_PLOC_RIGHTFOOTER )
return FALSE;
}
+
return FALSE;
}
@@ -417,13 +413,13 @@ long ScPreviewLocationData::GetNoteCountInRange( const Rectangle& rVisiblePixel,
ScPreviewLocationType eType = bNoteMarks ? SC_PLOC_NOTEMARK : SC_PLOC_NOTETEXT;
ULONG nRet = 0;
- ULONG nCount = aEntries.Count();
- for (ULONG nListPos=0; nListPos<nCount; nListPos++)
+ boost::ptr_list<ScPreviewLocationEntry>::const_iterator it;
+ for (it = aEntries.begin(); it != aEntries.end(); ++it)
{
- ScPreviewLocationEntry* pEntry = (ScPreviewLocationEntry*)aEntries.GetObject(nListPos);
- if ( pEntry->eType == eType && pEntry->aPixelRect.IsOver( rVisiblePixel ) )
+ if ( it->eType == eType && it->aPixelRect.IsOver( rVisiblePixel ) )
++nRet;
}
+
return nRet;
}
@@ -433,21 +429,21 @@ BOOL ScPreviewLocationData::GetNoteInRange( const Rectangle& rVisiblePixel, long
ScPreviewLocationType eType = bNoteMarks ? SC_PLOC_NOTEMARK : SC_PLOC_NOTETEXT;
ULONG nPos = 0;
- ULONG nCount = aEntries.Count();
- for (ULONG nListPos=0; nListPos<nCount; nListPos++)
+ boost::ptr_list<ScPreviewLocationEntry>::const_iterator it;
+ for (it = aEntries.begin(); it != aEntries.end(); ++it)
{
- ScPreviewLocationEntry* pEntry = (ScPreviewLocationEntry*)aEntries.GetObject(nListPos);
- if ( pEntry->eType == eType && pEntry->aPixelRect.IsOver( rVisiblePixel ) )
+ if ( it->eType == eType && it->aPixelRect.IsOver( rVisiblePixel ) )
{
if ( nPos == sal::static_int_cast<ULONG>(nIndex) )
{
- rCellPos = pEntry->aCellRange.aStart;
- rNoteRect = pEntry->aPixelRect;
+ rCellPos = it->aCellRange.aStart;
+ rNoteRect = it->aPixelRect;
return TRUE;
}
++nPos;
}
}
+
return FALSE;
}
@@ -456,17 +452,17 @@ Rectangle ScPreviewLocationData::GetNoteInRangeOutputRect(const Rectangle& rVisi
ScPreviewLocationType eType = bNoteMarks ? SC_PLOC_NOTEMARK : SC_PLOC_NOTETEXT;
ULONG nPos = 0;
- ULONG nCount = aEntries.Count();
- for (ULONG nListPos=0; nListPos<nCount; nListPos++)
+ boost::ptr_list<ScPreviewLocationEntry>::const_iterator it;
+ for (it = aEntries.begin(); it != aEntries.end(); ++it)
{
- ScPreviewLocationEntry* pEntry = (ScPreviewLocationEntry*)aEntries.GetObject(nListPos);
- if ( pEntry->eType == eType && pEntry->aPixelRect.IsOver( rVisiblePixel ) )
+ if ( it->eType == eType && it->aPixelRect.IsOver( rVisiblePixel ) )
{
- if ( aCellPos == pEntry->aCellRange.aStart )
- return pEntry->aPixelRect;
+ if ( aCellPos == it->aCellRange.aStart )
+ return it->aPixelRect;
++nPos;
}
}
+
return Rectangle();
}
@@ -496,59 +492,58 @@ void ScPreviewLocationData::GetTableInfo( const Rectangle& rVisiblePixel, ScPrev
Rectangle aHeaderRect, aRepeatRect, aMainRect;
SCTAB nTab = 0;
- ULONG nCount = aEntries.Count();
- for (ULONG nListPos=0; nListPos<nCount; nListPos++)
+ boost::ptr_list<ScPreviewLocationEntry>::const_iterator it;
+ for (it = aEntries.begin(); it != aEntries.end(); ++it)
{
- ScPreviewLocationEntry* pEntry = (ScPreviewLocationEntry*)aEntries.GetObject(nListPos);
- if ( pEntry->eType == SC_PLOC_CELLRANGE )
+ if ( it->eType == SC_PLOC_CELLRANGE )
{
- if ( pEntry->bRepeatCol )
+ if ( it->bRepeatCol )
{
bHasRepCols = TRUE;
- nRepeatColStart = pEntry->aCellRange.aStart.Col();
- nRepeatColEnd = pEntry->aCellRange.aEnd.Col();
- aRepeatRect.Left() = pEntry->aPixelRect.Left();
- aRepeatRect.Right() = pEntry->aPixelRect.Right();
+ nRepeatColStart = it->aCellRange.aStart.Col();
+ nRepeatColEnd = it->aCellRange.aEnd.Col();
+ aRepeatRect.Left() = it->aPixelRect.Left();
+ aRepeatRect.Right() = it->aPixelRect.Right();
}
else
{
bHasMainCols = TRUE;
- nMainColStart = pEntry->aCellRange.aStart.Col();
- nMainColEnd = pEntry->aCellRange.aEnd.Col();
- aMainRect.Left() = pEntry->aPixelRect.Left();
- aMainRect.Right() = pEntry->aPixelRect.Right();
+ nMainColStart = it->aCellRange.aStart.Col();
+ nMainColEnd = it->aCellRange.aEnd.Col();
+ aMainRect.Left() = it->aPixelRect.Left();
+ aMainRect.Right() = it->aPixelRect.Right();
}
- if ( pEntry->bRepeatRow )
+ if ( it->bRepeatRow )
{
bHasRepRows = TRUE;
- nRepeatRowStart = pEntry->aCellRange.aStart.Row();
- nRepeatRowEnd = pEntry->aCellRange.aEnd.Row();
- aRepeatRect.Top() = pEntry->aPixelRect.Top();
- aRepeatRect.Bottom() = pEntry->aPixelRect.Bottom();
+ nRepeatRowStart = it->aCellRange.aStart.Row();
+ nRepeatRowEnd = it->aCellRange.aEnd.Row();
+ aRepeatRect.Top() = it->aPixelRect.Top();
+ aRepeatRect.Bottom() = it->aPixelRect.Bottom();
}
else
{
bHasMainRows = TRUE;
- nMainRowStart = pEntry->aCellRange.aStart.Row();
- nMainRowEnd = pEntry->aCellRange.aEnd.Row();
- aMainRect.Top() = pEntry->aPixelRect.Top();
- aMainRect.Bottom() = pEntry->aPixelRect.Bottom();
+ nMainRowStart = it->aCellRange.aStart.Row();
+ nMainRowEnd = it->aCellRange.aEnd.Row();
+ aMainRect.Top() = it->aPixelRect.Top();
+ aMainRect.Bottom() = it->aPixelRect.Bottom();
}
- nTab = pEntry->aCellRange.aStart.Tab(); //! store separately?
+ nTab = it->aCellRange.aStart.Tab(); //! store separately?
}
- else if ( pEntry->eType == SC_PLOC_ROWHEADER )
+ else if ( it->eType == SC_PLOC_ROWHEADER )
{
// row headers result in an additional column
bHasHeaderCol = TRUE;
- aHeaderRect.Left() = pEntry->aPixelRect.Left();
- aHeaderRect.Right() = pEntry->aPixelRect.Right();
+ aHeaderRect.Left() = it->aPixelRect.Left();
+ aHeaderRect.Right() = it->aPixelRect.Right();
}
- else if ( pEntry->eType == SC_PLOC_COLHEADER )
+ else if ( it->eType == SC_PLOC_COLHEADER )
{
// column headers result in an additional row
bHasHeaderRow = TRUE;
- aHeaderRect.Top() = pEntry->aPixelRect.Top();
- aHeaderRect.Bottom() = pEntry->aPixelRect.Bottom();
+ aHeaderRect.Top() = it->aPixelRect.Top();
+ aHeaderRect.Bottom() = it->aPixelRect.Bottom();
}
}
@@ -739,18 +734,18 @@ Rectangle ScPreviewLocationData::GetCellOutputRect(const ScAddress& rCellPos) co
BOOL ScPreviewLocationData::GetMainCellRange( ScRange& rRange, Rectangle& rPixRect ) const
{
- ULONG nCount = aEntries.Count();
- for (ULONG nListPos=0; nListPos<nCount; nListPos++)
+ boost::ptr_list<ScPreviewLocationEntry>::const_iterator it;
+ for (it = aEntries.begin(); it != aEntries.end(); ++it)
{
- ScPreviewLocationEntry* pEntry = (ScPreviewLocationEntry*)aEntries.GetObject(nListPos);
- if ( pEntry->eType == SC_PLOC_CELLRANGE && !pEntry->bRepeatCol && !pEntry->bRepeatRow )
+ if ( it->eType == SC_PLOC_CELLRANGE && !it->bRepeatCol && !it->bRepeatRow )
{
- rRange = pEntry->aCellRange;
- rPixRect = pEntry->aPixelRect;
+ rRange = it->aCellRange;
+ rPixRect = it->aPixelRect;
return TRUE;
}
}
- return FALSE; // not found
+
+ return FALSE;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */