Kaydet (Commit) 3a085e0b authored tarafından Michael Stahl's avatar Michael Stahl

PPTParagraphObj: fix problems in previous commit:

- check for a null List element is actually check for valid index
- there may be any number of character properties for every paragraph,
  so need to pass in 2 parameters to PPTParagraphObj ctor
- PPTTextObj::PPTTextObj: nIdx became n in one place
- PPTTextObj::PPTTextObj: n++ dropped in one place

Change-Id: I590834012c46b7885ba5aa9c50655bf62439a0e9
üst 03ec685a
...@@ -1162,7 +1162,8 @@ public: ...@@ -1162,7 +1162,8 @@ public:
); );
PPTParagraphObj( PPTParagraphObj(
PPTStyleTextPropReader&, PPTStyleTextPropReader&,
sal_uInt32 nCurPos, size_t nCurParaPos,
size_t& rnCurCharPos,
const PPTStyleSheet&, const PPTStyleSheet&,
sal_uInt32 nInstance, sal_uInt32 nInstance,
PPTTextRulerInterpreter& rRuler PPTTextRulerInterpreter& rRuler
......
...@@ -5631,9 +5631,11 @@ PPTParagraphObj::PPTParagraphObj( const PPTStyleSheet& rStyleSheet, sal_uInt32 n ...@@ -5631,9 +5631,11 @@ PPTParagraphObj::PPTParagraphObj( const PPTStyleSheet& rStyleSheet, sal_uInt32 n
pParaSet->mnDepth = nDepth; pParaSet->mnDepth = nDepth;
} }
PPTParagraphObj::PPTParagraphObj( PPTStyleTextPropReader& rPropReader, sal_uInt32 nCurPos, const PPTStyleSheet& rStyleSheet, PPTParagraphObj::PPTParagraphObj( PPTStyleTextPropReader& rPropReader,
size_t const nCurParaPos, size_t& rnCurCharPos,
const PPTStyleSheet& rStyleSheet,
sal_uInt32 nInstance, PPTTextRulerInterpreter& rRuler ) : sal_uInt32 nInstance, PPTTextRulerInterpreter& rRuler ) :
PPTParaPropSet ( *rPropReader.aParaPropList[nCurPos] ), PPTParaPropSet ( *rPropReader.aParaPropList[nCurParaPos] ),
PPTNumberFormatCreator ( NULL ), PPTNumberFormatCreator ( NULL ),
PPTTextRulerInterpreter ( rRuler ), PPTTextRulerInterpreter ( rRuler ),
mrStyleSheet ( rStyleSheet ), mrStyleSheet ( rStyleSheet ),
...@@ -5643,18 +5645,18 @@ PPTParagraphObj::PPTParagraphObj( PPTStyleTextPropReader& rPropReader, sal_uInt3 ...@@ -5643,18 +5645,18 @@ PPTParagraphObj::PPTParagraphObj( PPTStyleTextPropReader& rPropReader, sal_uInt3
mnPortionCount ( 0 ), mnPortionCount ( 0 ),
mpPortionList ( NULL ) mpPortionList ( NULL )
{ {
PPTCharPropSet* pCharPropSet = rPropReader.aCharPropList[nCurPos]; if (rnCurCharPos < rPropReader.aCharPropList.size())
if ( pCharPropSet )
{ {
PPTCharPropSet* pCharPropSet = rPropReader.aCharPropList[rnCurCharPos];
sal_uInt32 nCurrentParagraph = pCharPropSet->mnParagraph; sal_uInt32 nCurrentParagraph = pCharPropSet->mnParagraph;
for ( sal_uInt32 n = nCurPos; for (size_t n = rnCurCharPos;
n < rPropReader.aCharPropList.size() && rPropReader.aCharPropList[n]->mnParagraph == nCurrentParagraph; ++n ) n < rPropReader.aCharPropList.size() && rPropReader.aCharPropList[n]->mnParagraph == nCurrentParagraph; ++n )
mnPortionCount++; // counting number of portions that are part of this paragraph mnPortionCount++; // counting number of portions that are part of this paragraph
mpPortionList = new PPTPortionObj*[ mnPortionCount ]; mpPortionList = new PPTPortionObj*[ mnPortionCount ];
for ( sal_uInt32 i = 0; i < mnPortionCount; i++ ) for ( sal_uInt32 i = 0; i < mnPortionCount; i++ )
{ {
pCharPropSet = rPropReader.aCharPropList[ nCurPos + i ]; pCharPropSet = rPropReader.aCharPropList[rnCurCharPos + i];
if ( pCharPropSet ) if ( pCharPropSet )
{ {
PPTPortionObj* pPPTPortion = new PPTPortionObj( *pCharPropSet, rStyleSheet, nInstance, pParaSet->mnDepth ); PPTPortionObj* pPPTPortion = new PPTPortionObj( *pCharPropSet, rStyleSheet, nInstance, pParaSet->mnDepth );
...@@ -5668,6 +5670,7 @@ PPTParagraphObj::PPTParagraphObj( PPTStyleTextPropReader& rPropReader, sal_uInt3 ...@@ -5668,6 +5670,7 @@ PPTParagraphObj::PPTParagraphObj( PPTStyleTextPropReader& rPropReader, sal_uInt3
mpPortionList[ i ] = NULL; mpPortionList[ i ] = NULL;
} }
} }
rnCurCharPos += mnPortionCount;
} }
} }
...@@ -6838,7 +6841,7 @@ PPTTextObj::PPTTextObj( SvStream& rIn, SdrPowerPointImport& rSdrPowerPointImport ...@@ -6838,7 +6841,7 @@ PPTTextObj::PPTTextObj( SvStream& rIn, SdrPowerPointImport& rSdrPowerPointImport
{ {
PPTCharPropSet* pNewCPS = new PPTCharPropSet( *pCurrent ); PPTCharPropSet* pNewCPS = new PPTCharPropSet( *pCurrent );
pNewCPS->maString = String( pCurrent->maString, (sal_uInt16)nHyperLenLeft, (sal_uInt16)( nNextStringLen - nHyperLenLeft ) ); pNewCPS->maString = String( pCurrent->maString, (sal_uInt16)nHyperLenLeft, (sal_uInt16)( nNextStringLen - nHyperLenLeft ) );
aCharPropList.insert( aCharPropList.begin() + n + 1, pNewCPS ); aCharPropList.insert( aCharPropList.begin() + nIdx + 1, pNewCPS );
String aRepresentation( pCurrent->maString, 0, (sal_uInt16)nHyperLenLeft ); String aRepresentation( pCurrent->maString, 0, (sal_uInt16)nHyperLenLeft );
pCurrent->mpFieldItem = new SvxFieldItem( SvxURLField( pField->GetURL(), aRepresentation, SVXURLFORMAT_REPR ), EE_FEATURE_FIELD ); pCurrent->mpFieldItem = new SvxFieldItem( SvxURLField( pField->GetURL(), aRepresentation, SVXURLFORMAT_REPR ), EE_FEATURE_FIELD );
nHyperLenLeft = 0; nHyperLenLeft = 0;
...@@ -6854,7 +6857,7 @@ PPTTextObj::PPTTextObj( SvStream& rIn, SdrPowerPointImport& rSdrPowerPointImport ...@@ -6854,7 +6857,7 @@ PPTTextObj::PPTTextObj( SvStream& rIn, SdrPowerPointImport& rSdrPowerPointImport
{ {
pBefCPS->maString = String( aString, (sal_uInt16)0, (sal_uInt16)nCount ); pBefCPS->maString = String( aString, (sal_uInt16)0, (sal_uInt16)nCount );
aCharPropList.insert( aCharPropList.begin() + n, pBefCPS ); aCharPropList.insert( aCharPropList.begin() + n, pBefCPS );
n++;
} }
} }
} }
...@@ -6869,9 +6872,14 @@ PPTTextObj::PPTTextObj( SvStream& rIn, SdrPowerPointImport& rSdrPowerPointImport ...@@ -6869,9 +6872,14 @@ PPTTextObj::PPTTextObj( SvStream& rIn, SdrPowerPointImport& rSdrPowerPointImport
} }
} }
mpImplTextObj->mpParagraphList = new PPTParagraphObj*[ nParagraphs ]; mpImplTextObj->mpParagraphList = new PPTParagraphObj*[ nParagraphs ];
for ( sal_uInt32 nCurPos = 0; nCurPos < aStyleTextPropReader.aParaPropList.size(); ++nCurPos ) for (size_t nCurCharPos = 0, nCurPos = 0;
nCurPos < aStyleTextPropReader.aParaPropList.size();
++nCurPos)
{ {
PPTParagraphObj* pPara = new PPTParagraphObj( aStyleTextPropReader, nCurPos, *rSdrPowerPointImport.pPPTStyleSheet, nInstance, aTextRulerInterpreter ); PPTParagraphObj* pPara = new PPTParagraphObj(
aStyleTextPropReader, nCurPos, nCurCharPos,
*rSdrPowerPointImport.pPPTStyleSheet,
nInstance, aTextRulerInterpreter );
mpImplTextObj->mpParagraphList[ nCurPos ] = pPara; mpImplTextObj->mpParagraphList[ nCurPos ] = pPara;
sal_uInt32 nParaAdjust, nFlags = 0; sal_uInt32 nParaAdjust, nFlags = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment