diff options
author | Luboš Luňák <l.lunak@suse.cz> | 2012-03-29 08:14:07 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@suse.cz> | 2012-03-29 08:14:07 +0200 |
commit | 571876c1234ae55aab0198c7e2caf9049fcd230e (patch) | |
tree | f923c212ad698c77a6c17ce4c3b5ae4b5e96198f /editeng | |
parent | I assume the asserts are safer before non-checked access (diff) | |
download | core-571876c1234ae55aab0198c7e2caf9049fcd230e.tar.gz core-571876c1234ae55aab0198c7e2caf9049fcd230e.zip |
SaveGetObject() is presumably meant to be safe rather than saving
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/editeng/editdoc.cxx | 6 | ||||
-rw-r--r-- | editeng/source/editeng/editdoc.hxx | 8 | ||||
-rw-r--r-- | editeng/source/editeng/editdoc2.cxx | 6 | ||||
-rw-r--r-- | editeng/source/editeng/editeng.cxx | 30 | ||||
-rw-r--r-- | editeng/source/editeng/editundo.cxx | 8 | ||||
-rw-r--r-- | editeng/source/editeng/eertfpar.cxx | 10 | ||||
-rw-r--r-- | editeng/source/editeng/impedit.cxx | 6 | ||||
-rw-r--r-- | editeng/source/editeng/impedit2.cxx | 70 | ||||
-rw-r--r-- | editeng/source/editeng/impedit3.cxx | 28 | ||||
-rw-r--r-- | editeng/source/editeng/impedit4.cxx | 16 | ||||
-rw-r--r-- | editeng/source/editeng/impedit5.cxx | 26 |
11 files changed, 107 insertions, 107 deletions
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx index 010f40f04df7..43c64c4f3eca 100644 --- a/editeng/source/editeng/editdoc.cxx +++ b/editeng/source/editeng/editdoc.cxx @@ -1341,12 +1341,12 @@ static const sal_Unicode aCR[] = { 0x0d, 0x00 }; static const sal_Unicode aLF[] = { 0x0a, 0x00 }; static const sal_Unicode aCRLF[] = { 0x0d, 0x0a, 0x00 }; -const ContentNode* EditDoc::SaveGetObject(size_t nPos) const +const ContentNode* EditDoc::SafeGetObject(size_t nPos) const { return ( nPos < Count() ) ? GetObject( nPos ) : 0; } -ContentNode* EditDoc::SaveGetObject(size_t nPos) +ContentNode* EditDoc::SafeGetObject(size_t nPos) { return ( nPos < Count() ) ? GetObject( nPos ) : 0; } @@ -1400,7 +1400,7 @@ XubString EditDoc::GetText( LineEnd eEnd ) const XubString EditDoc::GetParaAsString( sal_uInt16 nNode ) const { - return GetParaAsString( SaveGetObject( nNode ) ); + return GetParaAsString( SafeGetObject( nNode ) ); } XubString EditDoc::GetParaAsString( diff --git a/editeng/source/editeng/editdoc.hxx b/editeng/source/editeng/editdoc.hxx index 0114c099e681..59010d6feb7e 100644 --- a/editeng/source/editeng/editdoc.hxx +++ b/editeng/source/editeng/editdoc.hxx @@ -658,8 +658,8 @@ public: long GetYOffset(const ParaPortion* pPPortion) const; sal_uInt16 FindParagraph(long nYOffset) const; - const ParaPortion* SaveGetObject(size_t nPos) const; - ParaPortion* SaveGetObject(size_t nPos); + const ParaPortion* SafeGetObject(size_t nPos) const; + ParaPortion* SafeGetObject(size_t nPos); sal_uInt16 GetPos(const ParaPortion* p) const; ParaPortion* operator[](size_t nPos); @@ -805,8 +805,8 @@ public: void FindAttribs( ContentNode* pNode, sal_uInt16 nStartPos, sal_uInt16 nEndPos, SfxItemSet& rCurSet ); sal_uInt16 GetPos( const ContentNode* pNode ) const { return ContentList::GetPos(pNode); } - const ContentNode* SaveGetObject(size_t nPos) const; - ContentNode* SaveGetObject(size_t nPos); + const ContentNode* SafeGetObject(size_t nPos) const; + ContentNode* SafeGetObject(size_t nPos); static XubString GetSepStr( LineEnd eEnd ); }; diff --git a/editeng/source/editeng/editdoc2.cxx b/editeng/source/editeng/editdoc2.cxx index 474e3fa782cf..b22c10bcbd4e 100644 --- a/editeng/source/editeng/editdoc2.cxx +++ b/editeng/source/editeng/editdoc2.cxx @@ -460,12 +460,12 @@ sal_uInt16 ParaPortionList::FindParagraph(long nYOffset) const return EE_PARA_NOT_FOUND; } -const ParaPortion* ParaPortionList::SaveGetObject(size_t nPos) const +const ParaPortion* ParaPortionList::SafeGetObject(size_t nPos) const { return nPos < maPortions.size() ? &maPortions[nPos] : NULL; } -ParaPortion* ParaPortionList::SaveGetObject(size_t nPos) +ParaPortion* ParaPortionList::SafeGetObject(size_t nPos) { return nPos < maPortions.size() ? &maPortions[nPos] : NULL; } @@ -476,7 +476,7 @@ void ParaPortionList::DbgCheck( EditDoc& rDoc) DBG_ASSERT( Count() == rDoc.Count(), "ParaPortionList::DbgCheck() - Count() unequal!" ); for ( sal_uInt16 i = 0; i < Count(); i++ ) { - DBG_ASSERT( SaveGetObject(i), "ParaPortionList::DbgCheck() - Null-Pointer in List!" ); + DBG_ASSERT( SafeGetObject(i), "ParaPortionList::DbgCheck() - Null-Pointer in List!" ); DBG_ASSERT( GetObject(i)->GetNode(), "ParaPortionList::DbgCheck() - Null-Pointer in List(2)!" ); DBG_ASSERT( GetObject(i)->GetNode() == rDoc.GetObject(i), "ParaPortionList::DbgCheck() - Entries intersect!" ); } diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx index 275a992a0f95..2b246c90e588 100644 --- a/editeng/source/editeng/editeng.cxx +++ b/editeng/source/editeng/editeng.cxx @@ -503,7 +503,7 @@ sal_uInt16 EditEngine::GetScriptType( const ESelection& rSelection ) const LanguageType EditEngine::GetLanguage( sal_uInt16 nPara, sal_uInt16 nPos ) const { DBG_CHKTHIS( EditEngine, 0 ); - ContentNode* pNode = pImpEditEngine->GetEditDoc().SaveGetObject( nPara ); + ContentNode* pNode = pImpEditEngine->GetEditDoc().SafeGetObject( nPara ); DBG_ASSERT( pNode, "GetLanguage - nPara is invalid!" ); return pNode ? pImpEditEngine->GetLanguage( EditPaM( pNode, nPos ) ) : LANGUAGE_DONTKNOW; } @@ -1322,8 +1322,8 @@ EditTextObject* EditEngine::CreateTextObject( sal_uInt16 nPara, sal_uInt16 nPara DBG_ASSERT( nPara < pImpEditEngine->GetEditDoc().Count(), "CreateTextObject: Startpara out of Range" ); DBG_ASSERT( nPara+nParas-1 < pImpEditEngine->GetEditDoc().Count(), "CreateTextObject: Endpara out of Range" ); - ContentNode* pStartNode = pImpEditEngine->GetEditDoc().SaveGetObject( nPara ); - ContentNode* pEndNode = pImpEditEngine->GetEditDoc().SaveGetObject( nPara+nParas-1 ); + ContentNode* pStartNode = pImpEditEngine->GetEditDoc().SafeGetObject( nPara ); + ContentNode* pEndNode = pImpEditEngine->GetEditDoc().SafeGetObject( nPara+nParas-1 ); DBG_ASSERT( pStartNode, "Start-Paragraph does not exist: CreateTextObject" ); DBG_ASSERT( pEndNode, "End-Paragraph does not exist: CreateTextObject" ); @@ -1344,8 +1344,8 @@ void EditEngine::RemoveParagraph( sal_uInt16 nPara ) if( pImpEditEngine->GetEditDoc().Count() <= 1 ) return; - ContentNode* pNode = pImpEditEngine->GetEditDoc().SaveGetObject( nPara ); - const ParaPortion* pPortion = pImpEditEngine->GetParaPortions().SaveGetObject( nPara ); + ContentNode* pNode = pImpEditEngine->GetEditDoc().SafeGetObject( nPara ); + const ParaPortion* pPortion = pImpEditEngine->GetParaPortions().SafeGetObject( nPara ); DBG_ASSERT( pPortion && pNode, "Paragraph not found: RemoveParagraph" ); if ( pNode && pPortion ) { @@ -1360,7 +1360,7 @@ void EditEngine::RemoveParagraph( sal_uInt16 nPara ) sal_uInt16 EditEngine::GetTextLen( sal_uInt16 nPara ) const { DBG_CHKTHIS( EditEngine, 0 ); - ContentNode* pNode = pImpEditEngine->GetEditDoc().SaveGetObject( nPara ); + ContentNode* pNode = pImpEditEngine->GetEditDoc().SafeGetObject( nPara ); DBG_ASSERT( pNode, "Paragraph not found: GetTextLen" ); if ( pNode ) return pNode->Len(); @@ -1535,7 +1535,7 @@ Font EditEngine::GetStandardFont( sal_uInt16 nPara ) SvxFont EditEngine::GetStandardSvxFont( sal_uInt16 nPara ) { DBG_CHKTHIS( EditEngine, 0 ); - ContentNode* pNode = pImpEditEngine->GetEditDoc().SaveGetObject( nPara ); + ContentNode* pNode = pImpEditEngine->GetEditDoc().SafeGetObject( nPara ); return pNode->GetCharAttribs().GetDefFont(); } @@ -1557,7 +1557,7 @@ void EditEngine::GetPortions( sal_uInt16 nPara, std::vector<sal_uInt16>& rList ) if ( !pImpEditEngine->IsFormatted() ) pImpEditEngine->FormatFullDoc(); - const ParaPortion* pParaPortion = pImpEditEngine->GetParaPortions().SaveGetObject( nPara ); + const ParaPortion* pParaPortion = pImpEditEngine->GetParaPortions().SafeGetObject( nPara ); if ( pParaPortion ) { sal_uInt16 nEnd = 0; @@ -1669,7 +1669,7 @@ long EditEngine::GetFirstLineStartX( sal_uInt16 nParagraph ) DBG_CHKTHIS( EditEngine, 0 ); long nX = 0; - const ParaPortion* pPPortion = pImpEditEngine->GetParaPortions().SaveGetObject( nParagraph ); + const ParaPortion* pPPortion = pImpEditEngine->GetParaPortions().SafeGetObject( nParagraph ); if ( pPPortion ) { DBG_ASSERT( pImpEditEngine->IsFormatted() || !pImpEditEngine->IsFormatting(), "GetFirstLineStartX: Doc not formatted - unable to format!" ); @@ -1695,7 +1695,7 @@ Point EditEngine::GetDocPos( const Point& rPaperPos ) const Point EditEngine::GetDocPosTopLeft( sal_uInt16 nParagraph ) { DBG_CHKTHIS( EditEngine, 0 ); - const ParaPortion* pPPortion = pImpEditEngine->GetParaPortions().SaveGetObject( nParagraph ); + const ParaPortion* pPPortion = pImpEditEngine->GetParaPortions().SafeGetObject( nParagraph ); DBG_ASSERT( pPPortion, "Paragraph not found: GetWindowPosTopLeft" ); Point aPoint; if ( pPPortion ) @@ -1803,7 +1803,7 @@ void EditEngine::QuickMarkInvalid( const ESelection& rSel ) DBG_ASSERT( rSel.nEndPara < pImpEditEngine->GetEditDoc().Count(), "MarkInvalid: End out of Range!" ); for ( sal_uInt16 nPara = rSel.nStartPara; nPara <= rSel.nEndPara; nPara++ ) { - ParaPortion* pPortion = pImpEditEngine->GetParaPortions().SaveGetObject( nPara ); + ParaPortion* pPortion = pImpEditEngine->GetParaPortions().SafeGetObject( nPara ); if ( pPortion ) pPortion->MarkSelectionInvalid( 0, pPortion->GetNode()->Len() ); } @@ -1832,7 +1832,7 @@ void EditEngine::QuickDelete( const ESelection& rSel ) void EditEngine::QuickMarkToBeRepainted( sal_uInt16 nPara ) { DBG_CHKTHIS( EditEngine, 0 ); - ParaPortion* pPortion = pImpEditEngine->GetParaPortions().SaveGetObject( nPara ); + ParaPortion* pPortion = pImpEditEngine->GetParaPortions().SafeGetObject( nPara ); if ( pPortion ) pPortion->SetMustRepaint( sal_True ); } @@ -2046,7 +2046,7 @@ sal_Bool EditEngine::ShouldCreateBigTextObject() const sal_uInt16 EditEngine::GetFieldCount( sal_uInt16 nPara ) const { sal_uInt16 nFields = 0; - ContentNode* pNode = pImpEditEngine->GetEditDoc().SaveGetObject( nPara ); + ContentNode* pNode = pImpEditEngine->GetEditDoc().SafeGetObject( nPara ); if ( pNode ) { const CharAttribList::AttribsType& rAttrs = pNode->GetCharAttribs().GetAttribs(); @@ -2063,7 +2063,7 @@ sal_uInt16 EditEngine::GetFieldCount( sal_uInt16 nPara ) const EFieldInfo EditEngine::GetFieldInfo( sal_uInt16 nPara, sal_uInt16 nField ) const { - ContentNode* pNode = pImpEditEngine->GetEditDoc().SaveGetObject( nPara ); + ContentNode* pNode = pImpEditEngine->GetEditDoc().SafeGetObject( nPara ); if ( pNode ) { sal_uInt16 nCurrentField = 0; @@ -2176,7 +2176,7 @@ EPosition EditEngine::FindDocPosition( const Point& rDocPos ) const Rectangle EditEngine::GetCharacterBounds( const EPosition& rPos ) const { Rectangle aBounds; - ContentNode* pNode = pImpEditEngine->GetEditDoc().SaveGetObject( rPos.nPara ); + ContentNode* pNode = pImpEditEngine->GetEditDoc().SafeGetObject( rPos.nPara ); // Check against index, not paragraph if ( pNode && ( rPos.nIndex < pNode->Len() ) ) diff --git a/editeng/source/editeng/editundo.cxx b/editeng/source/editeng/editundo.cxx index da8fbfd91b06..62443be2541f 100644 --- a/editeng/source/editeng/editundo.cxx +++ b/editeng/source/editeng/editundo.cxx @@ -205,7 +205,7 @@ void EditUndoDelContent::Redo() // pNode is no longer correct, if the paragraphs where merged // in between Undos - pContentNode = _pImpEE->GetEditDoc().SaveGetObject( nNode ); + pContentNode = _pImpEE->GetEditDoc().SafeGetObject( nNode ); DBG_ASSERT( pContentNode, "EditUndoDelContent::Redo(): Node?!" ); _pImpEE->GetParaPortions().Remove( nNode ); @@ -220,8 +220,8 @@ void EditUndoDelContent::Redo() _pImpEE->UpdateSelections(); ContentNode* pN = ( nNode < _pImpEE->GetEditDoc().Count() ) - ? _pImpEE->GetEditDoc().SaveGetObject( nNode ) - : _pImpEE->GetEditDoc().SaveGetObject( nNode-1 ); + ? _pImpEE->GetEditDoc().SafeGetObject( nNode ) + : _pImpEE->GetEditDoc().SafeGetObject( nNode-1 ); DBG_ASSERT( pN && ( pN != pContentNode ), "?! RemoveContent !? " ); EditPaM aPaM( pN, pN->Len() ); @@ -576,7 +576,7 @@ void EditUndoSetAttribs::Undo() // Then the character attributes ... // Remove all attributes including features, are later re-established. _pImpEE->RemoveCharAttribs(nPara, 0, true); - DBG_ASSERT( _pImpEE->GetEditDoc().SaveGetObject( nPara ), "Undo (SetAttribs): pNode = NULL!" ); + DBG_ASSERT( _pImpEE->GetEditDoc().SafeGetObject( nPara ), "Undo (SetAttribs): pNode = NULL!" ); ContentNode* pNode = _pImpEE->GetEditDoc().GetObject( nPara ); for (size_t nAttr = 0; nAttr < rInf.GetPrevCharAttribs().size(); ++nAttr) { diff --git a/editeng/source/editeng/eertfpar.cxx b/editeng/source/editeng/eertfpar.cxx index 8322cd9d1326..262459ac90d7 100644 --- a/editeng/source/editeng/eertfpar.cxx +++ b/editeng/source/editeng/eertfpar.cxx @@ -132,7 +132,7 @@ SvParserState EditRTFParser::CallParser() { ContentNode* pCurNode = aCurSel.Max().GetNode(); sal_uInt16 nPara = pImpEditEngine->GetEditDoc().GetPos( pCurNode ); - ContentNode* pPrevNode = pImpEditEngine->GetEditDoc().SaveGetObject( nPara-1 ); + ContentNode* pPrevNode = pImpEditEngine->GetEditDoc().SafeGetObject( nPara-1 ); DBG_ASSERT( pPrevNode, "Invalid RTF-Document?!" ); EditSelection aSel; aSel.Min() = EditPaM( pPrevNode, pPrevNode->Len() ); @@ -178,7 +178,7 @@ void EditRTFParser::AddRTFDefaultValues( const EditPaM& rStart, const EditPaM& r sal_uInt16 nEndPara = pImpEditEngine->GetEditDoc().GetPos( rEnd.GetNode() ); for ( sal_uInt16 nPara = nStartPara; nPara <= nEndPara; nPara++ ) { - ContentNode* pNode = pImpEditEngine->GetEditDoc().SaveGetObject( nPara ); + ContentNode* pNode = pImpEditEngine->GetEditDoc().SafeGetObject( nPara ); DBG_ASSERT( pNode, "AddRTFDefaultValues - No paragraph?!" ); if ( !pNode->GetContentAttribs().HasItem( EE_CHAR_FONTINFO ) ) pNode->GetContentAttribs().GetItems().Put( aFontItem ); @@ -296,7 +296,7 @@ void EditRTFParser::SetEndPrevPara( SvxNodeIdx*& rpNodePos, DBG_ASSERT( nCurPara != 0, "Paragraph equal to 0: SetEnfPrevPara" ); if ( nCurPara ) nCurPara--; - ContentNode* pPrevNode = pImpEditEngine->GetEditDoc().SaveGetObject( nCurPara ); + ContentNode* pPrevNode = pImpEditEngine->GetEditDoc().SafeGetObject( nCurPara ); DBG_ASSERT( pPrevNode, "pPrevNode = 0!" ); rpNodePos = new EditNodeIdx( pImpEditEngine, pPrevNode ); rCntPos = pPrevNode->Len(); @@ -388,7 +388,7 @@ void EditRTFParser::SetAttrInDoc( SvxRTFItemStackType &rSet ) // All Complete paragraphs are paragraph attributes ... for ( sal_uInt16 z = nStartNode+1; z < nEndNode; z++ ) { - DBG_ASSERT( pImpEditEngine->GetEditDoc().SaveGetObject( z ), "Node does not exist yet(RTF)" ); + DBG_ASSERT( pImpEditEngine->GetEditDoc().SafeGetObject( z ), "Node does not exist yet(RTF)" ); pImpEditEngine->SetParaAttribs( z, rSet.GetAttrSet() ); } @@ -426,7 +426,7 @@ void EditRTFParser::SetAttrInDoc( SvxRTFItemStackType &rSet ) { for ( sal_uInt16 n = nStartNode; n <= nEndNode; n++ ) { - ContentNode* pNode = pImpEditEngine->GetEditDoc().SaveGetObject( n ); + ContentNode* pNode = pImpEditEngine->GetEditDoc().SafeGetObject( n ); pNode->GetContentAttribs().GetItems().Put( SfxInt16Item( EE_PARA_OUTLLEVEL, nOutlLevel ) ); } } diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx index 273f3f14dc04..062622e2975b 100644 --- a/editeng/source/editeng/impedit.cxx +++ b/editeng/source/editeng/impedit.cxx @@ -183,7 +183,7 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, Region* pRegion ) sal_uInt16 nEndPara = pEditEngine->pImpEditEngine->GetEditDoc().GetPos( pEndNode ); for ( sal_uInt16 nPara = nStartPara; nPara <= nEndPara; nPara++ ) { - ParaPortion* pTmpPortion = pEditEngine->pImpEditEngine->GetParaPortions().SaveGetObject( nPara ); + ParaPortion* pTmpPortion = pEditEngine->pImpEditEngine->GetParaPortions().SafeGetObject( nPara ); DBG_ASSERT( pTmpPortion, "Portion in Selection not found!" ); DBG_ASSERT( !pTmpPortion->IsInvalid(), "Portion in Selection not formatted!" ); @@ -1849,7 +1849,7 @@ void ImpEditView::dragOver( const ::com::sun::star::datatransfer::dnd::DropTarge if ( pDragAndDropInfo->bOutlinerMode ) { sal_uInt16 nPara = pEditEngine->pImpEditEngine->aEditDoc.GetPos( aPaM.GetNode() ); - ParaPortion* pPPortion = pEditEngine->pImpEditEngine->GetParaPortions().SaveGetObject( nPara ); + ParaPortion* pPPortion = pEditEngine->pImpEditEngine->GetParaPortions().SafeGetObject( nPara ); long nDestParaStartY = pEditEngine->pImpEditEngine->GetParaPortions().GetYOffset( pPPortion ); long nRel = aDocPos.Y() - nDestParaStartY; if ( nRel < ( pPPortion->GetHeight() / 2 ) ) @@ -1887,7 +1887,7 @@ void ImpEditView::dragOver( const ::com::sun::star::datatransfer::dnd::DropTarge long nDDYPos; if ( pDragAndDropInfo->nOutlinerDropDest < pEditEngine->pImpEditEngine->GetEditDoc().Count() ) { - ParaPortion* pPPortion = pEditEngine->pImpEditEngine->GetParaPortions().SaveGetObject( pDragAndDropInfo->nOutlinerDropDest ); + ParaPortion* pPPortion = pEditEngine->pImpEditEngine->GetParaPortions().SafeGetObject( pDragAndDropInfo->nOutlinerDropDest ); nDDYPos = pEditEngine->pImpEditEngine->GetParaPortions().GetYOffset( pPPortion ); } else diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index e7d2bbce7d47..a4654f0848b9 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -297,7 +297,7 @@ XubString ImpEditEngine::GetSelected( const EditSelection& rSel, const LineEnd e // iterate over the paragraphs ... for ( sal_uInt16 nNode = nStartNode; nNode <= nEndNode; nNode++ ) { - OSL_ENSURE( aEditDoc.SaveGetObject( nNode ), "Node not found: GetSelected" ); + OSL_ENSURE( aEditDoc.SafeGetObject( nNode ), "Node not found: GetSelected" ); const ContentNode* pNode = aEditDoc.GetObject( nNode ); xub_StrLen nStartPos = 0; @@ -602,7 +602,7 @@ void ImpEditEngine::Command( const CommandEvent& rCEvt, EditView* pView ) if ( !IsFormatted() ) FormatDoc(); - ParaPortion* pParaPortion = GetParaPortions().SaveGetObject( GetEditDoc().GetPos( aPaM.GetNode() ) ); + ParaPortion* pParaPortion = GetParaPortions().SafeGetObject( GetEditDoc().GetPos( aPaM.GetNode() ) ); sal_uInt16 nLine = pParaPortion->GetLines().FindLine( aPaM.GetIndex(), sal_True ); EditLine* pLine = pParaPortion->GetLines().GetObject( nLine ); if ( pLine && ( nInputEnd > pLine->GetEnd() ) ) @@ -819,7 +819,7 @@ void ImpEditEngine::ParaAttribsChanged( ContentNode* pNode ) sal_uInt16 nPara = aEditDoc.GetPos( pNode ); pEditEngine->ParaAttribsChanged( nPara ); - ParaPortion* pNextPortion = GetParaPortions().SaveGetObject( nPara+1 ); + ParaPortion* pNextPortion = GetParaPortions().SafeGetObject( nPara+1 ); // => is formatted again anyway, if Invalid. if ( pNextPortion && !pNextPortion->IsInvalid() ) CalcHeight( pNextPortion ); @@ -1006,7 +1006,7 @@ EditPaM ImpEditEngine::CursorVisualStartEnd( EditView* pEditView, const EditPaM& EditPaM aPaM( rPaM ); sal_uInt16 nPara = GetEditDoc().GetPos( aPaM.GetNode() ); - ParaPortion* pParaPortion = GetParaPortions().SaveGetObject( nPara ); + ParaPortion* pParaPortion = GetParaPortions().SafeGetObject( nPara ); sal_uInt16 nLine = pParaPortion->GetLines().FindLine( aPaM.GetIndex(), sal_False ); EditLine* pLine = pParaPortion->GetLines().GetObject( nLine ); @@ -1062,7 +1062,7 @@ EditPaM ImpEditEngine::CursorVisualLeftRight( EditView* pEditView, const EditPaM EditPaM aPaM( rPaM ); sal_uInt16 nPara = GetEditDoc().GetPos( aPaM.GetNode() ); - ParaPortion* pParaPortion = GetParaPortions().SaveGetObject( nPara ); + ParaPortion* pParaPortion = GetParaPortions().SafeGetObject( nPara ); sal_uInt16 nLine = pParaPortion->GetLines().FindLine( aPaM.GetIndex(), sal_False ); EditLine* pLine = pParaPortion->GetLines().GetObject( nLine ); @@ -1437,14 +1437,14 @@ EditPaM ImpEditEngine::CursorEndOfParagraph( const EditPaM& rPaM ) EditPaM ImpEditEngine::CursorStartOfDoc() { - EditPaM aPaM( aEditDoc.SaveGetObject( 0 ), 0 ); + EditPaM aPaM( aEditDoc.SafeGetObject( 0 ), 0 ); return aPaM; } EditPaM ImpEditEngine::CursorEndOfDoc() { - ContentNode* pLastNode = aEditDoc.SaveGetObject( aEditDoc.Count()-1 ); - ParaPortion* pLastPortion = GetParaPortions().SaveGetObject( aEditDoc.Count()-1 ); + ContentNode* pLastNode = aEditDoc.SafeGetObject( aEditDoc.Count()-1 ); + ParaPortion* pLastPortion = GetParaPortions().SafeGetObject( aEditDoc.Count()-1 ); OSL_ENSURE( pLastNode && pLastPortion, "CursorEndOfDoc: Node or Portion not found" ); if ( !pLastPortion->IsVisible() ) @@ -1452,7 +1452,7 @@ EditPaM ImpEditEngine::CursorEndOfDoc() pLastNode = GetPrevVisNode( pLastPortion->GetNode() ); OSL_ENSURE( pLastNode, "Kein sichtbarer Absatz?" ); if ( !pLastNode ) - pLastNode = aEditDoc.SaveGetObject( aEditDoc.Count()-1 ); + pLastNode = aEditDoc.SafeGetObject( aEditDoc.Count()-1 ); } EditPaM aPaM( pLastNode, pLastNode->Len() ); @@ -1494,7 +1494,7 @@ EditPaM ImpEditEngine::WordLeft( const EditPaM& rPaM, sal_Int16 nWordType ) { // Previous paragraph... sal_uInt16 nCurPara = aEditDoc.GetPos( aNewPaM.GetNode() ); - ContentNode* pPrevNode = aEditDoc.SaveGetObject( --nCurPara ); + ContentNode* pPrevNode = aEditDoc.SafeGetObject( --nCurPara ); if ( pPrevNode ) { aNewPaM.SetNode( pPrevNode ); @@ -1542,7 +1542,7 @@ EditPaM ImpEditEngine::WordRight( const EditPaM& rPaM, sal_Int16 nWordType ) { // Next paragraph ... sal_uInt16 nCurPara = aEditDoc.GetPos( aNewPaM.GetNode() ); - ContentNode* pNextNode = aEditDoc.SaveGetObject( ++nCurPara ); + ContentNode* pNextNode = aEditDoc.SafeGetObject( ++nCurPara ); if ( pNextNode ) { aNewPaM.SetNode( pNextNode ); @@ -1676,7 +1676,7 @@ sal_Bool ImpEditEngine::IsInputSequenceCheckingRequired( sal_Unicode nChar, cons void ImpEditEngine::InitScriptTypes( sal_uInt16 nPara ) { - ParaPortion* pParaPortion = GetParaPortions().SaveGetObject( nPara ); + ParaPortion* pParaPortion = GetParaPortions().SafeGetObject( nPara ); ScriptTypePosInfos& rTypes = pParaPortion->aScriptInfos; rTypes.clear(); @@ -1818,7 +1818,7 @@ sal_uInt16 ImpEditEngine::GetScriptType( const EditPaM& rPaM, sal_uInt16* pEndPo if ( rPaM.GetNode()->Len() ) { sal_uInt16 nPara = GetEditDoc().GetPos( rPaM.GetNode() ); - const ParaPortion* pParaPortion = GetParaPortions().SaveGetObject( nPara ); + const ParaPortion* pParaPortion = GetParaPortions().SafeGetObject( nPara ); if ( pParaPortion->aScriptInfos.empty() ) ((ImpEditEngine*)this)->InitScriptTypes( nPara ); @@ -1850,7 +1850,7 @@ sal_uInt16 ImpEditEngine::GetScriptType( const EditSelection& rSel ) const for ( sal_uInt16 nPara = nStartPara; nPara <= nEndPara; nPara++ ) { - const ParaPortion* pParaPortion = GetParaPortions().SaveGetObject( nPara ); + const ParaPortion* pParaPortion = GetParaPortions().SafeGetObject( nPara ); if ( pParaPortion->aScriptInfos.empty() ) ((ImpEditEngine*)this)->InitScriptTypes( nPara ); @@ -1891,7 +1891,7 @@ sal_Bool ImpEditEngine::IsScriptChange( const EditPaM& rPaM ) const if ( rPaM.GetNode()->Len() ) { sal_uInt16 nPara = GetEditDoc().GetPos( rPaM.GetNode() ); - const ParaPortion* pParaPortion = GetParaPortions().SaveGetObject( nPara ); + const ParaPortion* pParaPortion = GetParaPortions().SafeGetObject( nPara ); if ( pParaPortion->aScriptInfos.empty() ) ((ImpEditEngine*)this)->InitScriptTypes( nPara ); @@ -1913,7 +1913,7 @@ sal_Bool ImpEditEngine::HasScriptType( sal_uInt16 nPara, sal_uInt16 nType ) cons { bool bTypeFound = false; - const ParaPortion* pParaPortion = GetParaPortions().SaveGetObject( nPara ); + const ParaPortion* pParaPortion = GetParaPortions().SafeGetObject( nPara ); if ( pParaPortion->aScriptInfos.empty() ) ((ImpEditEngine*)this)->InitScriptTypes( nPara ); @@ -1928,7 +1928,7 @@ sal_Bool ImpEditEngine::HasScriptType( sal_uInt16 nPara, sal_uInt16 nType ) cons void ImpEditEngine::InitWritingDirections( sal_uInt16 nPara ) { - ParaPortion* pParaPortion = GetParaPortions().SaveGetObject( nPara ); + ParaPortion* pParaPortion = GetParaPortions().SafeGetObject( nPara ); WritingDirectionInfos& rInfos = pParaPortion->aWritingDirectionInfos; rInfos.clear(); @@ -2014,7 +2014,7 @@ sal_Bool ImpEditEngine::IsRightToLeft( sal_uInt16 nPara ) const sal_Bool ImpEditEngine::HasDifferentRTLLevels( const ContentNode* pNode ) { sal_uInt16 nPara = GetEditDoc().GetPos( (ContentNode*)pNode ); - ParaPortion* pParaPortion = GetParaPortions().SaveGetObject( nPara ); + ParaPortion* pParaPortion = GetParaPortions().SafeGetObject( nPara ); sal_Bool bHasDifferentRTLLevels = sal_False; @@ -2036,10 +2036,10 @@ sal_uInt8 ImpEditEngine::GetRightToLeft( sal_uInt16 nPara, sal_uInt16 nPos, sal_ { sal_uInt8 nRightToLeft = 0; - ContentNode* pNode = aEditDoc.SaveGetObject( nPara ); + ContentNode* pNode = aEditDoc.SafeGetObject( nPara ); if ( pNode && pNode->Len() ) { - ParaPortion* pParaPortion = GetParaPortions().SaveGetObject( nPara ); + ParaPortion* pParaPortion = GetParaPortions().SafeGetObject( nPara ); if ( pParaPortion->aWritingDirectionInfos.empty() ) InitWritingDirections( nPara ); @@ -2185,7 +2185,7 @@ EditSelection ImpEditEngine::ImpMoveParagraphs( Range aOldPositions, sal_uInt16 InsertUndo( new EditUndoMoveParagraphs( this, aOldPositions, nNewPos ) ); // do not lose sight of the Position ! - ParaPortion* pDestPortion = GetParaPortions().SaveGetObject( nNewPos ); + ParaPortion* pDestPortion = GetParaPortions().SafeGetObject( nNewPos ); ParaPortionList aTmpPortionList; for (sal_uInt16 i = (sal_uInt16)aOldPositions.Min(); i <= (sal_uInt16)aOldPositions.Max(); i++ ) @@ -2475,8 +2475,8 @@ EditPaM ImpEditEngine::ImpDeleteSelection( EditSelection aSel ) void ImpEditEngine::ImpRemoveParagraph( sal_uInt16 nPara ) { - ContentNode* pNode = aEditDoc.SaveGetObject( nPara ); - ContentNode* pNextNode = aEditDoc.SaveGetObject( nPara+1 ); + ContentNode* pNode = aEditDoc.SafeGetObject( nPara ); + ContentNode* pNextNode = aEditDoc.SafeGetObject( nPara+1 ); OSL_ENSURE( pNode, "Blind Node in ImpRemoveParagraph" ); @@ -2897,7 +2897,7 @@ EditPaM ImpEditEngine::ImpFastInsertParagraph( sal_uInt16 nPara ) { if ( nPara ) { - OSL_ENSURE( aEditDoc.SaveGetObject( nPara-1 ), "FastInsertParagraph: Prev does not exist" ); + OSL_ENSURE( aEditDoc.SafeGetObject( nPara-1 ), "FastInsertParagraph: Prev does not exist" ); InsertUndo( new EditUndoSplitPara( this, nPara-1, aEditDoc.GetObject( nPara-1 )->Len() ) ); } else @@ -3059,7 +3059,7 @@ EditPaM ImpEditEngine::GetPaM( Point aDocPos, sal_Bool bSmart ) while ( pPortion && !pPortion->IsVisible() ) { nPortion++; - pPortion = GetParaPortions().SaveGetObject( nPortion ); + pPortion = GetParaPortions().SafeGetObject( nPortion ); } OSL_ENSURE( pPortion, "No visible paragraph found: GetPaM" ); aPaM = GetPaM( pPortion, aDocPos, bSmart ); @@ -3236,7 +3236,7 @@ sal_uInt32 ImpEditEngine::CalcTextHeight( sal_uInt32* pHeightNTP ) sal_uInt16 ImpEditEngine::GetLineCount( sal_uInt16 nParagraph ) const { OSL_ENSURE( nParagraph < GetParaPortions().Count(), "GetLineCount: Out of range" ); - const ParaPortion* pPPortion = GetParaPortions().SaveGetObject( nParagraph ); + const ParaPortion* pPPortion = GetParaPortions().SafeGetObject( nParagraph ); OSL_ENSURE( pPPortion, "Paragraph not found: GetLineCount" ); if ( pPPortion ) return pPPortion->GetLines().Count(); @@ -3247,7 +3247,7 @@ sal_uInt16 ImpEditEngine::GetLineCount( sal_uInt16 nParagraph ) const xub_StrLen ImpEditEngine::GetLineLen( sal_uInt16 nParagraph, sal_uInt16 nLine ) const { OSL_ENSURE( nParagraph < GetParaPortions().Count(), "GetLineLen: Out of range" ); - const ParaPortion* pPPortion = GetParaPortions().SaveGetObject( nParagraph ); + const ParaPortion* pPPortion = GetParaPortions().SafeGetObject( nParagraph ); OSL_ENSURE( pPPortion, "Paragraph not found: GetLineLen" ); if ( pPPortion && ( nLine < pPPortion->GetLines().Count() ) ) { @@ -3262,7 +3262,7 @@ xub_StrLen ImpEditEngine::GetLineLen( sal_uInt16 nParagraph, sal_uInt16 nLine ) void ImpEditEngine::GetLineBoundaries( /*out*/sal_uInt16 &rStart, /*out*/sal_uInt16 &rEnd, sal_uInt16 nParagraph, sal_uInt16 nLine ) const { OSL_ENSURE( nParagraph < GetParaPortions().Count(), "GetLineCount: Out of range" ); - const ParaPortion* pPPortion = GetParaPortions().SaveGetObject( nParagraph ); + const ParaPortion* pPPortion = GetParaPortions().SafeGetObject( nParagraph ); OSL_ENSURE( pPPortion, "Paragraph not found: GetLineBoundaries" ); rStart = rEnd = 0xFFFF; // default values in case of error if ( pPPortion && ( nLine < pPPortion->GetLines().Count() ) ) @@ -3277,7 +3277,7 @@ void ImpEditEngine::GetLineBoundaries( /*out*/sal_uInt16 &rStart, /*out*/sal_uIn sal_uInt16 ImpEditEngine::GetLineNumberAtIndex( sal_uInt16 nPara, sal_uInt16 nIndex ) const { sal_uInt16 nLineNo = 0xFFFF; - const ContentNode* pNode = GetEditDoc().SaveGetObject( nPara ); + const ContentNode* pNode = GetEditDoc().SafeGetObject( nPara ); OSL_ENSURE( pNode, "GetLineNumberAtIndex: invalid paragraph index" ); if (pNode) { @@ -3304,7 +3304,7 @@ sal_uInt16 ImpEditEngine::GetLineNumberAtIndex( sal_uInt16 nPara, sal_uInt16 nIn sal_uInt16 ImpEditEngine::GetLineHeight( sal_uInt16 nParagraph, sal_uInt16 nLine ) { OSL_ENSURE( nParagraph < GetParaPortions().Count(), "GetLineCount: Out of range" ); - ParaPortion* pPPortion = GetParaPortions().SaveGetObject( nParagraph ); + ParaPortion* pPPortion = GetParaPortions().SafeGetObject( nParagraph ); OSL_ENSURE( pPPortion, "Paragraph not found: GetLineHeight" ); if ( pPPortion && ( nLine < pPPortion->GetLines().Count() ) ) { @@ -3320,7 +3320,7 @@ sal_uInt32 ImpEditEngine::GetParaHeight( sal_uInt16 nParagraph ) { sal_uInt32 nHeight = 0; - ParaPortion* pPPortion = GetParaPortions().SaveGetObject( nParagraph ); + ParaPortion* pPPortion = GetParaPortions().SafeGetObject( nParagraph ); OSL_ENSURE( pPPortion, "Paragraph not found: GetParaHeight" ); if ( pPPortion ) @@ -3350,7 +3350,7 @@ void ImpEditEngine::UpdateSelections() // Use ParaPortions, as now also hidden paragraphs have to be // taken into account! sal_uInt16 nPara = pInf->GetPosition(); - ParaPortion* pPPortion = GetParaPortions().SaveGetObject( nPara ); + ParaPortion* pPPortion = GetParaPortions().SafeGetObject( nPara ); if ( !pPPortion ) // Last paragraph { nPara = GetParaPortions().Count()-1; @@ -3408,7 +3408,7 @@ EditSelection ImpEditEngine::ConvertSelection( EditSelection aNewSelection; // Start... - ContentNode* pNode = aEditDoc.SaveGetObject( nStartPara ); + ContentNode* pNode = aEditDoc.SafeGetObject( nStartPara ); sal_uInt16 nIndex = nStartPos; if ( !pNode ) { @@ -3422,7 +3422,7 @@ EditSelection ImpEditEngine::ConvertSelection( aNewSelection.Min().SetIndex( nIndex ); // End... - pNode = aEditDoc.SaveGetObject( nEndPara ); + pNode = aEditDoc.SafeGetObject( nEndPara ); nIndex = nEndPos; if ( !pNode ) { @@ -4111,7 +4111,7 @@ void ImpEditEngine::CalcHeight( ParaPortion* pPortion ) if ( nPortion && !aStatus.ULSpaceSummation() ) { - ParaPortion* pPrev = GetParaPortions().SaveGetObject( nPortion-1 ); + ParaPortion* pPrev = GetParaPortions().SafeGetObject( nPortion-1 ); const SvxULSpaceItem& rPrevULItem = (const SvxULSpaceItem&)pPrev->GetNode()->GetContentAttribs().GetItem( EE_PARA_ULSPACE ); const SvxLineSpacingItem& rPrevLSItem = (const SvxLineSpacingItem&)pPrev->GetNode()->GetContentAttribs().GetItem( EE_PARA_SBL ); diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx index 14cf4e468892..88a2e73a470f 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -3557,7 +3557,7 @@ void ImpEditEngine::Paint( ImpEditView* pView, const Rectangle& rRec, sal_Bool b Color aBackgroundColor( pView->GetBackgroundColor() ); // #i47161# Check if text is visible on background SvxFont aTmpFont; - ContentNode* pNode = GetEditDoc().SaveGetObject( 0 ); + ContentNode* pNode = GetEditDoc().SafeGetObject( 0 ); SeekCursor( pNode, 1, aTmpFont ); Color aFontColor( aTmpFont.GetColor() ); if( (aFontColor == COL_AUTO) || IsForceAutoColor() ) @@ -3727,7 +3727,7 @@ void ImpEditEngine::InsertContent( ContentNode* pNode, sal_uInt16 nPos ) EditPaM ImpEditEngine::SplitContent( sal_uInt16 nNode, sal_uInt16 nSepPos ) { - ContentNode* pNode = aEditDoc.SaveGetObject( nNode ); + ContentNode* pNode = aEditDoc.SafeGetObject( nNode ); DBG_ASSERT( pNode, "Invalid Node in SplitContent" ); DBG_ASSERT( IsInUndo(), "SplitContent only for Undo()!" ); DBG_ASSERT( nSepPos <= pNode->Len(), "Index out of range: SplitContent" ); @@ -3737,8 +3737,8 @@ EditPaM ImpEditEngine::SplitContent( sal_uInt16 nNode, sal_uInt16 nSepPos ) EditPaM ImpEditEngine::ConnectContents( sal_uInt16 nLeftNode, sal_Bool bBackward ) { - ContentNode* pLeftNode = aEditDoc.SaveGetObject( nLeftNode ); - ContentNode* pRightNode = aEditDoc.SaveGetObject( nLeftNode+1 ); + ContentNode* pLeftNode = aEditDoc.SafeGetObject( nLeftNode ); + ContentNode* pRightNode = aEditDoc.SafeGetObject( nLeftNode+1 ); DBG_ASSERT( pLeftNode, "Invalid left node in ConnectContents "); DBG_ASSERT( pRightNode, "Invalid right node in ConnectContents "); DBG_ASSERT( IsInUndo(), "ConnectContent only for Undo()!" ); @@ -3762,7 +3762,7 @@ void ImpEditEngine::SetUpdateMode( sal_Bool bUp, EditView* pCurView, sal_Bool bF void ImpEditEngine::ShowParagraph( sal_uInt16 nParagraph, sal_Bool bShow ) { - ParaPortion* pPPortion = GetParaPortions().SaveGetObject( nParagraph ); + ParaPortion* pPPortion = GetParaPortions().SafeGetObject( nParagraph ); DBG_ASSERT( pPPortion, "ShowParagraph: Paragraph does not exist! "); if ( pPPortion && ( pPPortion->IsVisible() != bShow ) ) { @@ -3834,8 +3834,8 @@ EditSelection ImpEditEngine::MoveParagraphs( Range aOldPositions, sal_uInt16 nNe sal_uInt16 nFirstPortion = Min( (sal_uInt16)aOldPositions.Min(), nNewPos ); sal_uInt16 nLastPortion = Max( (sal_uInt16)aOldPositions.Max(), nNewPos ); - ParaPortion* pUpperPortion = GetParaPortions().SaveGetObject( nFirstPortion ); - ParaPortion* pLowerPortion = GetParaPortions().SaveGetObject( nLastPortion ); + ParaPortion* pUpperPortion = GetParaPortions().SafeGetObject( nFirstPortion ); + ParaPortion* pLowerPortion = GetParaPortions().SafeGetObject( nLastPortion ); aInvalidRec = Rectangle(); // make empty aInvalidRec.Left() = 0; @@ -3927,9 +3927,9 @@ const ParaPortion* ImpEditEngine::GetNextVisPortion( const ParaPortion* pCurPort { sal_uInt16 nPara = GetParaPortions().GetPos( pCurPortion ); DBG_ASSERT( nPara < GetParaPortions().Count() , "Portion not found: GetPrevVisNode" ); - const ParaPortion* pPortion = GetParaPortions().SaveGetObject( ++nPara ); + const ParaPortion* pPortion = GetParaPortions().SafeGetObject( ++nPara ); while ( pPortion && !pPortion->IsVisible() ) - pPortion = GetParaPortions().SaveGetObject( ++nPara ); + pPortion = GetParaPortions().SafeGetObject( ++nPara ); return pPortion; } @@ -3987,15 +3987,15 @@ EditPaM ImpEditEngine::InsertParagraph( sal_uInt16 nPara ) EditPaM aPaM; if ( nPara != 0 ) { - ContentNode* pNode = GetEditDoc().SaveGetObject( nPara-1 ); + ContentNode* pNode = GetEditDoc().SafeGetObject( nPara-1 ); if ( !pNode ) - pNode = GetEditDoc().SaveGetObject( GetEditDoc().Count() - 1 ); + pNode = GetEditDoc().SafeGetObject( GetEditDoc().Count() - 1 ); DBG_ASSERT( pNode, "Not a single paragraph in InsertParagraph ?" ); aPaM = EditPaM( pNode, pNode->Len() ); } else { - ContentNode* pNode = GetEditDoc().SaveGetObject( 0 ); + ContentNode* pNode = GetEditDoc().SafeGetObject( 0 ); aPaM = EditPaM( pNode, 0 ); } @@ -4005,7 +4005,7 @@ EditPaM ImpEditEngine::InsertParagraph( sal_uInt16 nPara ) EditSelection* ImpEditEngine::SelectParagraph( sal_uInt16 nPara ) { EditSelection* pSel = 0; - ContentNode* pNode = GetEditDoc().SaveGetObject( nPara ); + ContentNode* pNode = GetEditDoc().SafeGetObject( nPara ); DBG_ASSERTWARNING( pNode, "Paragraph does not exist: SelectParagraph" ); if ( pNode ) pSel = new EditSelection( EditPaM( pNode, 0 ), EditPaM( pNode, pNode->Len() ) ); @@ -4192,7 +4192,7 @@ void ImpEditEngine::ImplInitLayoutMode( OutputDevice* pOutDev, sal_uInt16 nPara, } else { - ContentNode* pNode = GetEditDoc().SaveGetObject( nPara ); + ContentNode* pNode = GetEditDoc().SafeGetObject( nPara ); short nScriptType = GetScriptType( EditPaM( pNode, nIndex+1 ) ); bCTL = nScriptType == i18n::ScriptType::COMPLEX; bR2L = GetRightToLeft( nPara, nIndex + 1); // this change was discussed in issue 37190 diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx index c5b89fd8e366..4863e4840b25 100644 --- a/editeng/source/editeng/impedit4.cxx +++ b/editeng/source/editeng/impedit4.cxx @@ -551,7 +551,7 @@ sal_uInt32 ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel ) rOutput << '{' << endl; for ( sal_uInt16 nNode = nStartNode; nNode <= nEndNode; nNode++ ) { - ContentNode* pNode = aEditDoc.SaveGetObject( nNode ); + ContentNode* pNode = aEditDoc.SafeGetObject( nNode ); DBG_ASSERT( pNode, "Node not found: Search&Replace" ); // The paragraph attributes in advance ... @@ -1057,7 +1057,7 @@ EditTextObject* ImpEditEngine::CreateBinTextObject( EditSelection aSel, SfxItemP sal_uInt16 nNode; for ( nNode = nStartNode; nNode <= nEndNode; nNode++ ) { - ContentNode* pNode = aEditDoc.SaveGetObject( nNode ); + ContentNode* pNode = aEditDoc.SafeGetObject( nNode ); DBG_ASSERT( pNode, "Node not found: Search&Replace" ); if ( bOnlyFullParagraphs ) @@ -1658,7 +1658,7 @@ void ImpEditEngine::ImpConvert( rtl::OUString &rConvTxt, LanguageType &rConvTxtL String aRes; LanguageType nResLang = LANGUAGE_NONE; - /* ContentNode* pLastNode = */ aEditDoc.SaveGetObject( aEditDoc.Count()-1 ); + /* ContentNode* pLastNode = */ aEditDoc.SafeGetObject( aEditDoc.Count()-1 ); EditPaM aPos( CreateEditPaM( pConvInfo->aConvContinue ) ); EditSelection aCurSel = EditSelection( aPos, aPos ); @@ -1820,7 +1820,7 @@ Reference< XSpellAlternatives > ImpEditEngine::ImpSpell( EditView* pEditView ) { DBG_ASSERT( xSpeller.is(), "No spell checker set!" ); - ContentNode* pLastNode = aEditDoc.SaveGetObject( (aEditDoc.Count()-1) ); + ContentNode* pLastNode = aEditDoc.SafeGetObject( (aEditDoc.Count()-1) ); EditSelection aCurSel( pEditView->pImpEditView->GetEditSelection() ); aCurSel.Min() = aCurSel.Max(); @@ -1892,7 +1892,7 @@ void ImpEditEngine::StartSpelling(EditView& rEditView, sal_Bool bMultipleDoc) Reference< XSpellAlternatives > ImpEditEngine::ImpFindNextError(EditSelection& rSelection) { - /* ContentNode* pLastNode = */ aEditDoc.SaveGetObject( (aEditDoc.Count()-1) ); + /* ContentNode* pLastNode = */ aEditDoc.SafeGetObject( (aEditDoc.Count()-1) ); EditSelection aCurSel( rSelection.Min() ); String aWord; @@ -1952,7 +1952,7 @@ bool ImpEditEngine::SpellSentence(EditView& rEditView, //if no selection previously exists the range is extended to the end of the object if(aCurSel.Min() == aCurSel.Max()) { - ContentNode* pLastNode = aEditDoc.SaveGetObject( aEditDoc.Count()-1); + ContentNode* pLastNode = aEditDoc.SafeGetObject( aEditDoc.Count()-1); aCurSel.Max() = EditPaM(pLastNode, pLastNode->Len()); } // check for next error in aCurSel and set aCurSel to that one if any was found @@ -2248,7 +2248,7 @@ void ImpEditEngine::DoOnlineSpelling( ContentNode* pThisNodeOnly, sal_Bool bSpel } sal_Bool bRestartTimer = sal_False; - ContentNode* pLastNode = aEditDoc.SaveGetObject( aEditDoc.Count() - 1 ); + ContentNode* pLastNode = aEditDoc.SafeGetObject( aEditDoc.Count() - 1 ); sal_uInt16 nNodes = GetEditDoc().Count(); sal_uInt16 nInvalids = 0; Sequence< PropertyValue > aEmptySeq; @@ -2432,7 +2432,7 @@ EESpellState ImpEditEngine::HasSpellErrors() { DBG_ASSERT( xSpeller.is(), "No spell checker set!" ); - ContentNode* pLastNode = aEditDoc.SaveGetObject( aEditDoc.Count() - 1 ); + ContentNode* pLastNode = aEditDoc.SafeGetObject( aEditDoc.Count() - 1 ); EditSelection aCurSel( aEditDoc.GetStartPaM() ); String aWord; diff --git a/editeng/source/editeng/impedit5.cxx b/editeng/source/editeng/impedit5.cxx index 4174ce05b47f..46fab2cf55c9 100644 --- a/editeng/source/editeng/impedit5.cxx +++ b/editeng/source/editeng/impedit5.cxx @@ -48,13 +48,13 @@ void ImpEditEngine::SetStyleSheetPool( SfxStyleSheetPool* pSPool ) const SfxStyleSheet* ImpEditEngine::GetStyleSheet( sal_uInt16 nPara ) const { - const ContentNode* pNode = aEditDoc.SaveGetObject( nPara ); + const ContentNode* pNode = aEditDoc.SafeGetObject( nPara ); return pNode ? pNode->GetContentAttribs().GetStyleSheet() : NULL; } SfxStyleSheet* ImpEditEngine::GetStyleSheet( sal_uInt16 nPara ) { - ContentNode* pNode = aEditDoc.SaveGetObject( nPara ); + ContentNode* pNode = aEditDoc.SafeGetObject( nPara ); return pNode ? pNode->GetContentAttribs().GetStyleSheet() : NULL; } @@ -77,7 +77,7 @@ void ImpEditEngine::SetStyleSheet( EditSelection aSel, SfxStyleSheet* pStyle ) void ImpEditEngine::SetStyleSheet( sal_uInt16 nPara, SfxStyleSheet* pStyle ) { DBG_ASSERT( GetStyleSheetPool() || !pStyle, "SetStyleSheet: No StyleSheetPool registered!" ); - ContentNode* pNode = aEditDoc.SaveGetObject( nPara ); + ContentNode* pNode = aEditDoc.SafeGetObject( nPara ); SfxStyleSheet* pCurStyle = pNode->GetStyleSheet(); if ( pStyle != pCurStyle ) { @@ -217,7 +217,7 @@ EditUndoSetAttribs* ImpEditEngine::CreateAttribUndo( EditSelection aSel, const S for ( sal_uInt16 nPara = nStartNode; nPara <= nEndNode; nPara++ ) { ContentNode* pNode = aEditDoc.GetObject( nPara ); - DBG_ASSERT( aEditDoc.SaveGetObject( nPara ), "Node not found: CreateAttribUndo" ); + DBG_ASSERT( aEditDoc.SafeGetObject( nPara ), "Node not found: CreateAttribUndo" ); ContentAttribsInfo* pInf = new ContentAttribsInfo( pNode->GetContentAttribs().GetItems() ); pUndo->AppendContentInfo(pInf); @@ -330,7 +330,7 @@ SfxItemSet ImpEditEngine::GetAttribs( EditSelection aSel, sal_Bool bOnlyHardAttr for ( sal_uInt16 nNode = nStartNode; nNode <= nEndNode; nNode++ ) { ContentNode* pNode = aEditDoc.GetObject( nNode ); - DBG_ASSERT( aEditDoc.SaveGetObject( nNode ), "Node not found: GetAttrib" ); + DBG_ASSERT( aEditDoc.SafeGetObject( nNode ), "Node not found: GetAttrib" ); xub_StrLen nStartPos = 0; xub_StrLen nEndPos = pNode->Len(); @@ -415,7 +415,7 @@ SfxItemSet ImpEditEngine::GetAttribs( sal_uInt16 nPara, sal_uInt16 nStart, sal_u DBG_CHKOBJ( GetEditEnginePtr(), EditEngine, 0 ); - ContentNode* pNode = const_cast<ContentNode*>(aEditDoc.SaveGetObject(nPara)); + ContentNode* pNode = const_cast<ContentNode*>(aEditDoc.SafeGetObject(nPara)); DBG_ASSERT( pNode, "GetAttribs - unknown paragraph!" ); DBG_ASSERT( nStart <= nEnd, "getAttribs: Start > End not supported!" ); @@ -532,8 +532,8 @@ void ImpEditEngine::SetAttribs( EditSelection aSel, const SfxItemSet& rSet, sal_ sal_Bool bParaAttribFound = sal_False; sal_Bool bCharAttribFound = sal_False; - DBG_ASSERT( aEditDoc.SaveGetObject( nNode ), "Node not founden: SetAttribs" ); - DBG_ASSERT( GetParaPortions().SaveGetObject( nNode ), "Portion not found: SetAttribs" ); + DBG_ASSERT( aEditDoc.SafeGetObject( nNode ), "Node not founden: SetAttribs" ); + DBG_ASSERT( GetParaPortions().SafeGetObject( nNode ), "Portion not found: SetAttribs" ); ContentNode* pNode = aEditDoc.GetObject( nNode ); ParaPortion* pPortion = GetParaPortions()[nNode]; @@ -622,8 +622,8 @@ void ImpEditEngine::RemoveCharAttribs( EditSelection aSel, sal_Bool bRemoveParaA ContentNode* pNode = aEditDoc.GetObject( nNode ); ParaPortion* pPortion = GetParaPortions()[nNode]; - DBG_ASSERT( aEditDoc.SaveGetObject( nNode ), "Node not found: SetAttribs" ); - DBG_ASSERT( GetParaPortions().SaveGetObject( nNode ), "Portion not found: SetAttribs" ); + DBG_ASSERT( aEditDoc.SafeGetObject( nNode ), "Node not found: SetAttribs" ); + DBG_ASSERT( GetParaPortions().SafeGetObject( nNode ), "Portion not found: SetAttribs" ); xub_StrLen nStartPos = 0; xub_StrLen nEndPos = pNode->Len(); @@ -667,8 +667,8 @@ typedef EditCharAttrib* EditCharAttribPtr; void ImpEditEngine::RemoveCharAttribs( sal_uInt16 nPara, sal_uInt16 nWhich, sal_Bool bRemoveFeatures ) { - ContentNode* pNode = aEditDoc.SaveGetObject( nPara ); - ParaPortion* pPortion = GetParaPortions().SaveGetObject( nPara ); + ContentNode* pNode = aEditDoc.SafeGetObject( nPara ); + ParaPortion* pPortion = GetParaPortions().SafeGetObject( nPara ); DBG_ASSERT( pNode, "Node not found: RemoveCharAttribs" ); DBG_ASSERT( pPortion, "Portion not found: RemoveCharAttribs" ); @@ -696,7 +696,7 @@ void ImpEditEngine::RemoveCharAttribs( sal_uInt16 nPara, sal_uInt16 nWhich, sal_ void ImpEditEngine::SetParaAttribs( sal_uInt16 nPara, const SfxItemSet& rSet ) { - ContentNode* pNode = aEditDoc.SaveGetObject( nPara ); + ContentNode* pNode = aEditDoc.SafeGetObject( nPara ); if ( !pNode ) return; |