diff options
author | Noel Grandin <noel@peralex.com> | 2013-09-06 12:01:31 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2013-09-11 09:45:30 +0200 |
commit | ac85b6cff11d193f5f71d11b1f3cc1c474653f59 (patch) | |
tree | c39ae299f09d993b963613b6af9869fbd0d8403e /editeng/source | |
parent | bde5457dd634c70cef02565890e08e8669e1a437 (diff) |
convert SvxAutoCorrDoc from String to OUString
Also:
- simplify the return type of the GetPrevPara method, there is no
need return an OUString by pointer
- simply the ppPara parameter of the ChgAutoCorrWord method,
passing a pointer to a pointer to a value type is unnecessary.
Change-Id: I4a8c44fdab1cf68af88c34003827d1c20704f839
Diffstat (limited to 'editeng/source')
-rw-r--r-- | editeng/source/editeng/edtspell.cxx | 30 | ||||
-rw-r--r-- | editeng/source/editeng/edtspell.hxx | 10 | ||||
-rw-r--r-- | editeng/source/misc/svxacorr.cxx | 24 |
3 files changed, 32 insertions, 32 deletions
diff --git a/editeng/source/editeng/edtspell.cxx b/editeng/source/editeng/edtspell.cxx index 6c2fdf741e09..787189c2a163 100644 --- a/editeng/source/editeng/edtspell.cxx +++ b/editeng/source/editeng/edtspell.cxx @@ -603,27 +603,27 @@ sal_Bool EdtAutoCorrDoc::Delete( sal_uInt16 nStt, sal_uInt16 nEnd ) return true; } -sal_Bool EdtAutoCorrDoc::Insert( sal_uInt16 nPos, const String& rTxt ) +sal_Bool EdtAutoCorrDoc::Insert( sal_uInt16 nPos, const OUString& rTxt ) { EditSelection aSel = EditPaM( pCurNode, nPos ); mpEditEngine->InsertText(aSel, rTxt); SAL_WARN_IF(nCursor < nPos, "editeng", "Cursor in the heart of the action?!"); - nCursor = nCursor + rTxt.Len(); + nCursor = nCursor + rTxt.getLength(); - if ( bAllowUndoAction && ( rTxt.Len() == 1 ) ) + if ( bAllowUndoAction && ( rTxt.getLength() == 1 ) ) ImplStartUndoAction(); bAllowUndoAction = false; return true; } -sal_Bool EdtAutoCorrDoc::Replace( sal_uInt16 nPos, const String& rTxt ) +sal_Bool EdtAutoCorrDoc::Replace( sal_uInt16 nPos, const OUString& rTxt ) { - return ReplaceRange( nPos, rTxt.Len(), rTxt ); + return ReplaceRange( nPos, rTxt.getLength(), rTxt ); } -sal_Bool EdtAutoCorrDoc::ReplaceRange( xub_StrLen nPos, xub_StrLen nSourceLength, const String& rTxt ) +sal_Bool EdtAutoCorrDoc::ReplaceRange( xub_StrLen nPos, xub_StrLen nSourceLength, const OUString& rTxt ) { // Actually a Replace introduce => corresponds to UNDO sal_uInt16 nEnd = nPos+nSourceLength; @@ -636,9 +636,9 @@ sal_Bool EdtAutoCorrDoc::ReplaceRange( xub_StrLen nPos, xub_StrLen nSourceLength EditSelection(EditPaM(pCurNode, nPos), EditPaM(pCurNode, nEnd))); if ( nPos == nCursor ) - nCursor = nCursor + rTxt.Len(); + nCursor = nCursor + rTxt.getLength(); - if ( bAllowUndoAction && ( rTxt.Len() == 1 ) ) + if ( bAllowUndoAction && ( rTxt.getLength() == 1 ) ) ImplStartUndoAction(); bAllowUndoAction = false; @@ -691,7 +691,7 @@ sal_Bool EdtAutoCorrDoc::SetINetAttr( sal_uInt16 nStt, sal_uInt16 nEnd, return true; } -const String* EdtAutoCorrDoc::GetPrevPara( sal_Bool ) +OUString EdtAutoCorrDoc::GetPrevPara( sal_Bool ) { // Return previous paragraph, so that it can be determined, // whether the current word is at the beginning of a sentence. @@ -714,22 +714,22 @@ const String* EdtAutoCorrDoc::GetPrevPara( sal_Bool ) bBullet = true; } if ( bBullet ) - return NULL; + return OUString(); for ( sal_Int32 n = nPos; n; ) { n--; ContentNode* pNode = rNodes[n]; if ( pNode->Len() ) - return &pNode->GetString(); + return pNode->GetString(); } - return NULL; + return OUString(); } sal_Bool EdtAutoCorrDoc::ChgAutoCorrWord( sal_uInt16& rSttPos, sal_uInt16 nEndPos, SvxAutoCorrect& rACorrect, - const String** ppPara ) + OUString* pPara ) { // Paragraph-start or a blank found, search for the word // shortcut in Auto @@ -754,8 +754,8 @@ sal_Bool EdtAutoCorrDoc::ChgAutoCorrWord( sal_uInt16& rSttPos, nCursor -= ( nEndPos-rSttPos ); mpEditEngine->InsertText(aSel, pFnd->GetLong()); nCursor = nCursor + pFnd->GetLong().Len(); - if( ppPara ) - *ppPara = &pCurNode->GetString(); + if( pPara ) + *pPara = pCurNode->GetString(); bRet = true; } diff --git a/editeng/source/editeng/edtspell.hxx b/editeng/source/editeng/edtspell.hxx index 8049b5f8509e..375dd780cdce 100644 --- a/editeng/source/editeng/edtspell.hxx +++ b/editeng/source/editeng/edtspell.hxx @@ -140,17 +140,17 @@ public: ~EdtAutoCorrDoc(); virtual sal_Bool Delete( sal_uInt16 nStt, sal_uInt16 nEnd ); - virtual sal_Bool Insert( sal_uInt16 nPos, const String& rTxt ); - virtual sal_Bool Replace( sal_uInt16 nPos, const String& rTxt ); - virtual sal_Bool ReplaceRange( xub_StrLen nPos, xub_StrLen nLen, const String& rTxt ); + virtual sal_Bool Insert( sal_uInt16 nPos, const OUString& rTxt ); + virtual sal_Bool Replace( sal_uInt16 nPos, const OUString& rTxt ); + virtual sal_Bool ReplaceRange( xub_StrLen nPos, xub_StrLen nLen, const OUString& rTxt ); virtual sal_Bool SetAttr( sal_uInt16 nStt, sal_uInt16 nEnd, sal_uInt16 nSlotId, SfxPoolItem& ); virtual sal_Bool SetINetAttr( sal_uInt16 nStt, sal_uInt16 nEnd, const OUString& rURL ); - virtual const String* GetPrevPara( sal_Bool bAtNormalPos ); + virtual OUString GetPrevPara( sal_Bool bAtNormalPos ); virtual sal_Bool ChgAutoCorrWord( sal_uInt16& rSttPos, sal_uInt16 nEndPos, - SvxAutoCorrect& rACorrect, const String** ppPara ); + SvxAutoCorrect& rACorrect, OUString* pPara ); virtual LanguageType GetLanguage( sal_uInt16 nPos, sal_Bool bPrevPara = sal_False ) const; diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx index 52fdb7c46423..fb7b339e0d05 100644 --- a/editeng/source/misc/svxacorr.cxx +++ b/editeng/source/misc/svxacorr.cxx @@ -175,7 +175,7 @@ SvxAutoCorrDoc::~SvxAutoCorrDoc() // - FnCptlSttSntnc // after the exchange of characters. Then the words, if necessary, can be inserted // into the exception list. -void SvxAutoCorrDoc::SaveCpltSttWord( sal_uLong, xub_StrLen, const String&, +void SvxAutoCorrDoc::SaveCpltSttWord( sal_uLong, xub_StrLen, const OUString&, sal_Unicode ) { } @@ -865,8 +865,8 @@ sal_Bool SvxAutoCorrect::FnCptlSttSntnc( SvxAutoCorrDoc& rDoc, { // Check out the previous paragraph, if it exists. // If so, then check to paragraph separator at the end. - const String* pPrevPara = rDoc.GetPrevPara( bNormalPos ); - if( !pPrevPara ) + OUString aPrevPara = rDoc.GetPrevPara( bNormalPos ); + if( !aPrevPara.isEmpty() ) { // valid separator -> replace OUString sChar( *pWordStt ); @@ -875,7 +875,7 @@ sal_Bool SvxAutoCorrect::FnCptlSttSntnc( SvxAutoCorrDoc& rDoc, rDoc.ReplaceRange( xub_StrLen( pWordStt - pStart ), 1, sChar ); } - aText = *pPrevPara; + aText = aPrevPara; bAtStart = sal_False; pStart = aText.GetBuffer(); pStr = pStart + aText.Len(); @@ -1324,11 +1324,11 @@ SvxAutoCorrect::DoAutoCorrect( SvxAutoCorrDoc& rDoc, const String& rTxt, if( IsAutoCorrFlag( Autocorrect ) ) { - const String* pPara = 0; - const String** ppPara = IsAutoCorrFlag(CptlSttSntnc) ? &pPara : 0; + OUString aPara; + OUString* pPara = IsAutoCorrFlag(CptlSttSntnc) ? &aPara : 0; sal_Bool bChgWord = rDoc.ChgAutoCorrWord( nCapLttrPos, nInsPos, - *this, ppPara ); + *this, pPara ); if( !bChgWord ) { xub_StrLen nCapLttrPos1 = nCapLttrPos, nInsPos1 = nInsPos; @@ -1343,7 +1343,7 @@ SvxAutoCorrect::DoAutoCorrect( SvxAutoCorrDoc& rDoc, const String& rTxt, if( (nCapLttrPos1 != nCapLttrPos || nInsPos1 != nInsPos ) && nCapLttrPos1 < nInsPos1 && - rDoc.ChgAutoCorrWord( nCapLttrPos1, nInsPos1, *this, ppPara )) + rDoc.ChgAutoCorrWord( nCapLttrPos1, nInsPos1, *this, pPara )) { bChgWord = sal_True; nCapLttrPos = nCapLttrPos1; @@ -1353,16 +1353,16 @@ SvxAutoCorrect::DoAutoCorrect( SvxAutoCorrDoc& rDoc, const String& rTxt, if( bChgWord ) { nRet = Autocorrect; - if( pPara ) + if( !aPara.isEmpty() ) { xub_StrLen nEnd = nCapLttrPos; - while( nEnd < pPara->Len() && - !IsWordDelim( pPara->GetChar( nEnd ))) + while( nEnd < aPara.getLength() && + !IsWordDelim( aPara[ nEnd ])) ++nEnd; // Capital letter at beginning of paragraph? if( IsAutoCorrFlag( CptlSttSntnc ) && - FnCptlSttSntnc( rDoc, *pPara, sal_False, + FnCptlSttSntnc( rDoc, aPara, sal_False, nCapLttrPos, nEnd, eLang ) ) nRet |= CptlSttSntnc; |