summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/source/filter/excel/xistyle.cxx30
-rw-r--r--sc/source/filter/inc/xistyle.hxx9
2 files changed, 22 insertions, 17 deletions
diff --git a/sc/source/filter/excel/xistyle.cxx b/sc/source/filter/excel/xistyle.cxx
index d4800d4d4c39..d6f8208ce54d 100644
--- a/sc/source/filter/excel/xistyle.cxx
+++ b/sc/source/filter/excel/xistyle.cxx
@@ -532,13 +532,14 @@ const XclImpFont* XclImpFontBuffer::GetFont( sal_uInt16 nFontIndex ) const
/* Font with index 4 is not stored in an Excel file, but used e.g. by
BIFF5 form pushbutton objects. It is the bold default font.
This also means that entries above 4 are out by one in the list. */
+
if (nFontIndex == 4)
return &maFont4;
- if ( (nFontIndex < 4) && (nFontIndex < maFontList.size()) )
- return &(maFontList[nFontIndex]);
- if ( (nFontIndex > 4) && (nFontIndex <= maFontList.size()) )
- return &(maFontList[nFontIndex - 1]);
- return 0;
+
+ if (nFontIndex >= maFontList.size())
+ return NULL;
+
+ return (nFontIndex < 4) ? &(maFontList[nFontIndex]) : &(maFontList[nFontIndex - 1]);
}
void XclImpFontBuffer::ReadFont( XclImpStream& rStrm )
@@ -1682,7 +1683,7 @@ void XclImpXFRangeColumn::Insert(XclImpXFRange* pXFRange, ULONG nIndex)
void XclImpXFRangeColumn::Find(
XclImpXFRange*& rpPrevRange, XclImpXFRange*& rpNextRange,
- ULONG& rnNextIndex, SCROW nScRow ) const
+ ULONG& rnNextIndex, SCROW nScRow )
{
// test whether list is empty
@@ -1693,8 +1694,8 @@ void XclImpXFRangeColumn::Find(
return;
}
- rpPrevRange = const_cast<XclImpXFRange*> (&(maIndexList.front()));
- rpNextRange = const_cast<XclImpXFRange*> (&(maIndexList.back()));
+ rpPrevRange = &maIndexList.front();
+ rpNextRange = &maIndexList.back();
// test whether row is at end of list (contained in or behind last range)
// rpPrevRange will contain a possible existing row
@@ -1725,7 +1726,7 @@ void XclImpXFRangeColumn::Find(
while( ((rnNextIndex - nPrevIndex) > 1) && (rpPrevRange->mnScRow2 < nScRow) )
{
nMidIndex = (nPrevIndex + rnNextIndex) / 2;
- pMidRange = const_cast<XclImpXFRange*>( &(maIndexList[ nMidIndex ]) );
+ pMidRange = &maIndexList[nMidIndex];
DBG_ASSERT( pMidRange, "XclImpXFRangeColumn::Find - missing XF index range" );
if( nScRow < pMidRange->mnScRow1 ) // row is really before pMidRange
{
@@ -1743,19 +1744,20 @@ void XclImpXFRangeColumn::Find(
if( nScRow <= rpPrevRange->mnScRow2 )
{
rnNextIndex = nPrevIndex + 1;
- rpNextRange = const_cast<XclImpXFRange*>( &(maIndexList[rnNextIndex]) );
+ rpNextRange = &maIndexList[rnNextIndex];
}
}
void XclImpXFRangeColumn::TryConcatPrev( ULONG nIndex )
{
- if( nIndex <= 0 || nIndex >= maIndexList.size() )
+ if( !nIndex || nIndex >= maIndexList.size() )
return;
- XclImpXFRange prevRange = maIndexList[ nIndex - 1 ];
- XclImpXFRange nextRange = maIndexList[ nIndex ];
+ XclImpXFRange& prevRange = maIndexList[ nIndex - 1 ];
+ XclImpXFRange& nextRange = maIndexList[ nIndex ];
- if( prevRange.Expand( nextRange ) ) {
+ if( prevRange.Expand( nextRange ) )
+ {
maIndexList.erase( maIndexList.begin() + nIndex );
if (mnCurIndex > nIndex)
--mnCurIndex;
diff --git a/sc/source/filter/inc/xistyle.hxx b/sc/source/filter/inc/xistyle.hxx
index f48db444402f..599d3847f704 100644
--- a/sc/source/filter/inc/xistyle.hxx
+++ b/sc/source/filter/inc/xistyle.hxx
@@ -497,8 +497,11 @@ public:
void ReadStyle( XclImpStream& rStrm );
/** Returns the object that stores all contents of an XF record. */
- inline XclImpXF* GetXF( sal_uInt16 nXFIndex ) const
- { return const_cast< XclImpXF* > ((nXFIndex >= maXFList.size()) ? 0 : &(maXFList.at(nXFIndex))); }
+ inline XclImpXF* GetXF( sal_uInt16 nXFIndex )
+ { return (nXFIndex >= maXFList.size()) ? NULL : &maXFList.at(nXFIndex); }
+
+ inline const XclImpXF* GetXF( sal_uInt16 nXFIndex ) const
+ { return (nXFIndex >= maXFList.size()) ? NULL : &maXFList.at(nXFIndex); }
/** Returns the index to the Excel font used in the specified XF record. */
sal_uInt16 GetFontIndex( sal_uInt16 nXFIndex ) const;
@@ -589,7 +592,7 @@ private:
XclImpXFRange*& rpPrevRange,
XclImpXFRange*& rpNextRange,
ULONG& rnNextIndex,
- SCROW nScRow ) const;
+ SCROW nScRow );
/** Tries to concatenate a range with its predecessor.
@descr The ranges must have the same XF index and must not have a gap.