summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2012-08-13 22:00:17 +0200
committerMichael Stahl <mstahl@redhat.com>2012-08-13 22:48:12 +0200
commitd037459ca5da62f0ae02a2796c661d41427e67ef (patch)
treed0b0dd416376cbb1bab11fd4401827dbad2c2946 /filter
parent3a085e0b7e9249310edffeabe1c48b06b9d1fae0 (diff)
PPTParagraphObj: replace PPTPortionObj array with boost::ptr_vector
Remove null pointer checks as well, we've been dereferencing them always since c21c2f82f9451c293c449e4647522d126a0f2bee (2001) already. Change-Id: I978745ab922f7975a785857f7d17add62e37baba
Diffstat (limited to 'filter')
-rw-r--r--filter/inc/filter/msfilter/svdfppt.hxx6
-rw-r--r--filter/source/msfilter/svdfppt.cxx134
2 files changed, 63 insertions, 77 deletions
diff --git a/filter/inc/filter/msfilter/svdfppt.hxx b/filter/inc/filter/msfilter/svdfppt.hxx
index 1940e67c50e0..b8d54544ed8b 100644
--- a/filter/inc/filter/msfilter/svdfppt.hxx
+++ b/filter/inc/filter/msfilter/svdfppt.hxx
@@ -46,6 +46,7 @@
#include <vcl/font.hxx>
#include <vector>
#include <boost/optional.hpp>
+#include <boost/ptr_container/ptr_vector.hpp>
class SdrModel;
class SdPage;
@@ -1100,7 +1101,7 @@ class MSFILTER_DLLPUBLIC PPTPortionObj : public PPTCharPropSet
public:
- sal_Bool GetAttrib( sal_uInt32 nAttr, sal_uInt32& nVal, sal_uInt32 nInstanceInSheet );
+ sal_Bool GetAttrib( sal_uInt32 nAttr, sal_uInt32& nVal, sal_uInt32 nInstanceInSheet ) const;
SvxFieldItem* GetTextField();
PPTPortionObj( const PPTStyleSheet&, sal_uInt32 nInstance, sal_uInt32 nDepth );
@@ -1149,8 +1150,7 @@ public:
sal_Bool mbTab; // if true, this paragraph has tabulators in text
sal_uInt32 mnCurrentObject;
- sal_uInt32 mnPortionCount;
- PPTPortionObj** mpPortionList;
+ ::boost::ptr_vector<PPTPortionObj> m_PortionList;
void UpdateBulletRelSize( sal_uInt32& nBulletRelSize ) const;
sal_Bool GetAttrib( sal_uInt32 nAttr, sal_uInt32& nVal, sal_uInt32 nInstanceInSheet );
diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index 06082c254c67..da00296ae501 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -5284,7 +5284,7 @@ sal_Bool PPTPortionObj::HasTabulator()
return bRetValue;
}
-sal_Bool PPTPortionObj::GetAttrib( sal_uInt32 nAttr, sal_uInt32& nRetValue, sal_uInt32 nDestinationInstance )
+sal_Bool PPTPortionObj::GetAttrib( sal_uInt32 nAttr, sal_uInt32& nRetValue, sal_uInt32 nDestinationInstance ) const
{
sal_uInt32 nMask = 1 << nAttr;
nRetValue = 0;
@@ -5622,9 +5622,7 @@ PPTParagraphObj::PPTParagraphObj( const PPTStyleSheet& rStyleSheet, sal_uInt32 n
PPTNumberFormatCreator ( NULL ),
mrStyleSheet ( rStyleSheet ),
mnInstance ( nInstance ),
- mbTab ( sal_True ), // style sheets always have to get the right tabulator setting
- mnPortionCount ( 0 ),
- mpPortionList ( NULL )
+ mbTab ( sal_True ) // style sheets always have to get the right tabulator setting
{
if ( nDepth > 4 )
nDepth = 4;
@@ -5641,36 +5639,26 @@ PPTParagraphObj::PPTParagraphObj( PPTStyleTextPropReader& rPropReader,
mrStyleSheet ( rStyleSheet ),
mnInstance ( nInstance ),
mbTab ( sal_False ),
- mnCurrentObject ( 0 ),
- mnPortionCount ( 0 ),
- mpPortionList ( NULL )
+ mnCurrentObject ( 0 )
{
if (rnCurCharPos < rPropReader.aCharPropList.size())
{
- PPTCharPropSet* pCharPropSet = rPropReader.aCharPropList[rnCurCharPos];
- sal_uInt32 nCurrentParagraph = pCharPropSet->mnParagraph;
- for (size_t n = rnCurCharPos;
- n < rPropReader.aCharPropList.size() && rPropReader.aCharPropList[n]->mnParagraph == nCurrentParagraph; ++n )
- mnPortionCount++; // counting number of portions that are part of this paragraph
-
- mpPortionList = new PPTPortionObj*[ mnPortionCount ];
- for ( sal_uInt32 i = 0; i < mnPortionCount; i++ )
+ sal_uInt32 const nCurrentParagraph =
+ rPropReader.aCharPropList[rnCurCharPos]->mnParagraph;
+ for (; rnCurCharPos < rPropReader.aCharPropList.size() &&
+ rPropReader.aCharPropList[rnCurCharPos]->mnParagraph == nCurrentParagraph;
+ ++rnCurCharPos)
{
- pCharPropSet = rPropReader.aCharPropList[rnCurCharPos + i];
- if ( pCharPropSet )
+ PPTCharPropSet *const pCharPropSet =
+ rPropReader.aCharPropList[rnCurCharPos];
+ PPTPortionObj* pPPTPortion = new PPTPortionObj( *pCharPropSet,
+ rStyleSheet, nInstance, pParaSet->mnDepth );
+ m_PortionList.push_back(pPPTPortion);
+ if (!mbTab)
{
- PPTPortionObj* pPPTPortion = new PPTPortionObj( *pCharPropSet, rStyleSheet, nInstance, pParaSet->mnDepth );
- mpPortionList[ i ] = pPPTPortion;
- if ( !mbTab )
- mbTab = mpPortionList[ i ]->HasTabulator();
- }
- else
- {
- OSL_FAIL( "SJ:PPTParagraphObj::It seems that there are missing some textportions" );
- mpPortionList[ i ] = NULL;
+ mbTab = pPPTPortion->HasTabulator();
}
}
- rnCurCharPos += mnPortionCount;
}
}
@@ -5681,15 +5669,11 @@ PPTParagraphObj::~PPTParagraphObj()
void PPTParagraphObj::AppendPortion( PPTPortionObj& rPPTPortion )
{
- sal_uInt32 i;
- PPTPortionObj** mpOldPortionList = mpPortionList;
- mpPortionList = new PPTPortionObj*[ ++mnPortionCount ];
- for ( i = 0; i < mnPortionCount - 1; i++ )
- mpPortionList[ i ] = mpOldPortionList[ i ];
- delete[] mpOldPortionList;
- mpPortionList[ mnPortionCount - 1 ] = new PPTPortionObj( rPPTPortion );
+ m_PortionList.push_back(new PPTPortionObj(rPPTPortion));
if ( !mbTab )
- mbTab = mpPortionList[ mnPortionCount - 1 ]->HasTabulator();
+ {
+ mbTab = m_PortionList.back().HasTabulator();
+ }
}
void PPTParagraphObj::UpdateBulletRelSize( sal_uInt32& nBulletRelSize ) const
@@ -5697,11 +5681,13 @@ void PPTParagraphObj::UpdateBulletRelSize( sal_uInt32& nBulletRelSize ) const
if ( nBulletRelSize > 0x7fff ) // a negative value is the absolute bullet height
{
sal_uInt16 nFontHeight = 0;
- if ( mpPortionList )
+ if (!m_PortionList.empty())
{
- PPTPortionObj* pPortion = mpPortionList[ 0 ];
- if ( pPortion && ( pPortion->pCharSet->mnAttrSet & ( 1 << PPT_CharAttr_FontHeight ) ) )
- nFontHeight = pPortion->pCharSet->mnFontHeight;
+ PPTPortionObj const& rPortion = m_PortionList.front();
+ if (rPortion.pCharSet->mnAttrSet & (1 << PPT_CharAttr_FontHeight))
+ {
+ nFontHeight = rPortion.pCharSet->mnFontHeight;
+ }
}
// if we do not have a hard attributed fontheight, the fontheight is taken from the style
if ( !nFontHeight )
@@ -5738,15 +5724,16 @@ sal_Bool PPTParagraphObj::GetAttrib( sal_uInt32 nAttr, sal_uInt32& nRetValue, sa
else
{
nRetValue = PPT_COLSCHEME_TEXT_UND_ZEILEN;
- if ( ( nDestinationInstance != 0xffffffff ) && mnPortionCount )
+ if ((nDestinationInstance != 0xffffffff) && !m_PortionList.empty())
{
- PPTPortionObj* pPortion = mpPortionList[ 0 ];
- if ( pPortion )
+ PPTPortionObj const& rPortion = m_PortionList.front();
+ if (rPortion.pCharSet->mnAttrSet & (1 << PPT_CharAttr_FontColor))
{
- if ( pPortion->pCharSet->mnAttrSet & ( 1 << PPT_CharAttr_FontColor ) )
- nRetValue = pPortion->pCharSet->mnColor;
- else
- nRetValue = mrStyleSheet.mpCharSheet[ nDestinationInstance ]->maCharLevel[ pParaSet->mnDepth ].mnFontColor;
+ nRetValue = rPortion.pCharSet->mnColor;
+ }
+ else
+ {
+ nRetValue = mrStyleSheet.mpCharSheet[ nDestinationInstance ]->maCharLevel[ pParaSet->mnDepth ].mnFontColor;
}
}
}
@@ -5765,15 +5752,16 @@ sal_Bool PPTParagraphObj::GetAttrib( sal_uInt32 nAttr, sal_uInt32& nRetValue, sa
{
// it is the font used which assigned to the first character of the following text
nRetValue = 0;
- if ( ( nDestinationInstance != 0xffffffff ) && mnPortionCount )
+ if ((nDestinationInstance != 0xffffffff) && !m_PortionList.empty())
{
- PPTPortionObj* pPortion = mpPortionList[ 0 ];
- if ( pPortion )
+ PPTPortionObj const& rPortion = m_PortionList.front();
+ if (rPortion.pCharSet->mnAttrSet & ( 1 << PPT_CharAttr_Font ) )
{
- if ( pPortion->pCharSet->mnAttrSet & ( 1 << PPT_CharAttr_Font ) )
- nRetValue = pPortion->pCharSet->mnFont;
- else
- nRetValue = mrStyleSheet.mpCharSheet[ nDestinationInstance ]->maCharLevel[ pParaSet->mnDepth ].mnFont;
+ nRetValue = rPortion.pCharSet->mnFont;
+ }
+ else
+ {
+ nRetValue = mrStyleSheet.mpCharSheet[ nDestinationInstance ]->maCharLevel[ pParaSet->mnDepth ].mnFont;
}
}
}
@@ -5830,11 +5818,11 @@ sal_Bool PPTParagraphObj::GetAttrib( sal_uInt32 nAttr, sal_uInt32& nRetValue, sa
}
else
{
- if ( mnPortionCount )
+ if (!m_PortionList.empty())
{
- PPTPortionObj* pPortion = mpPortionList[ 0 ];
- if ( pPortion )
- bIsHardAttribute = pPortion->GetAttrib( PPT_CharAttr_Font, nRetValue, nDestinationInstance );
+ PPTPortionObj const& rPortion = m_PortionList.front();
+ bIsHardAttribute = rPortion.GetAttrib(
+ PPT_CharAttr_Font, nRetValue, nDestinationInstance);
}
else
{
@@ -5866,11 +5854,11 @@ sal_Bool PPTParagraphObj::GetAttrib( sal_uInt32 nAttr, sal_uInt32& nRetValue, sa
}
else
{
- if ( mnPortionCount )
+ if (!m_PortionList.empty())
{
- PPTPortionObj* pPortion = mpPortionList[ 0 ];
- if ( pPortion )
- bIsHardAttribute = pPortion->GetAttrib( PPT_CharAttr_FontColor, nRetValue, nDestinationInstance );
+ PPTPortionObj const& rPortion = m_PortionList.front();
+ bIsHardAttribute = rPortion.GetAttrib(
+ PPT_CharAttr_FontColor, nRetValue, nDestinationInstance);
}
else
{
@@ -6088,10 +6076,11 @@ void PPTParagraphObj::ApplyTo( SfxItemSet& rSet, boost::optional< sal_Int16 >&
(sal_uInt32)GetAttrib( PPT_ParaAttr_LowerDist, nLowerDist, nDestinationInstance ) ) != 0;
if ( ( nUpperDist > 0 ) || ( nLowerDist > 0 ) )
{
- if ( mnPortionCount )
+ if (!m_PortionList.empty())
{
sal_uInt32 nFontHeight = 0;
- mpPortionList[ mnPortionCount - 1 ]->GetAttrib( PPT_CharAttr_FontHeight, nFontHeight, nDestinationInstance );
+ m_PortionList.back().GetAttrib(
+ PPT_CharAttr_FontHeight, nFontHeight, nDestinationInstance);
if ( ((sal_Int16)nUpperDist) > 0 )
nUpperDist = - (sal_Int16)( ( nFontHeight * nUpperDist * 100 ) / 1000 );
if ( ((sal_Int16)nLowerDist) > 0 )
@@ -6168,11 +6157,11 @@ void PPTParagraphObj::ApplyTo( SfxItemSet& rSet, boost::optional< sal_Int16 >&
sal_uInt32 PPTParagraphObj::GetTextSize()
{
sal_uInt32 nCount, nRetValue = 0;
- for ( sal_uInt32 i = 0; i < mnPortionCount; i++ )
+ for (size_t i = 0; i < m_PortionList.size(); i++)
{
- PPTPortionObj* pPortionObj = mpPortionList[ i ];
- nCount = pPortionObj->Count();
- if ( ( !nCount ) && pPortionObj->mpFieldItem )
+ PPTPortionObj const& rPortionObj = m_PortionList[i];
+ nCount = rPortionObj.Count();
+ if ((!nCount) && rPortionObj.mpFieldItem)
nCount++;
nRetValue += nCount;
}
@@ -6182,25 +6171,22 @@ sal_uInt32 PPTParagraphObj::GetTextSize()
PPTPortionObj* PPTParagraphObj::First()
{
mnCurrentObject = 0;
- if ( !mnPortionCount )
+ if (m_PortionList.empty())
return NULL;
- return mpPortionList[ 0 ];
+ return &m_PortionList.front();
}
PPTPortionObj* PPTParagraphObj::Next()
{
sal_uInt32 i = mnCurrentObject + 1;
- if ( i >= mnPortionCount )
+ if (i >= m_PortionList.size())
return NULL;
mnCurrentObject++;
- return mpPortionList[ i ];
+ return &m_PortionList[i];
}
void PPTParagraphObj::ImplClear()
{
- for ( void* pPtr = First(); pPtr; pPtr = Next() )
- delete (PPTPortionObj*)pPtr;
- delete[] mpPortionList;
}
PPTFieldEntry::~PPTFieldEntry()