summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2013-09-06 12:01:31 +0200
committerNoel Grandin <noel@peralex.com>2013-09-11 09:45:30 +0200
commitac85b6cff11d193f5f71d11b1f3cc1c474653f59 (patch)
treec39ae299f09d993b963613b6af9869fbd0d8403e /sw
parentbde5457dd634c70cef02565890e08e8669e1a437 (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 'sw')
-rw-r--r--sw/source/core/edit/acorrect.cxx42
-rw-r--r--sw/source/core/inc/acorrect.hxx15
2 files changed, 27 insertions, 30 deletions
diff --git a/sw/source/core/edit/acorrect.cxx b/sw/source/core/edit/acorrect.cxx
index 936f3a800730..64bca9d96f99 100644
--- a/sw/source/core/edit/acorrect.cxx
+++ b/sw/source/core/edit/acorrect.cxx
@@ -123,14 +123,14 @@ sal_Bool SwAutoCorrDoc::Delete( xub_StrLen nStt, xub_StrLen nEnd )
return sal_True;
}
-sal_Bool SwAutoCorrDoc::Insert( xub_StrLen nPos, const String& rTxt )
+sal_Bool SwAutoCorrDoc::Insert( xub_StrLen nPos, const OUString& rTxt )
{
SwPaM aPam( rCrsr.GetPoint()->nNode.GetNode(), nPos );
rEditSh.GetDoc()->InsertString( aPam, rTxt );
if( !bUndoIdInitialized )
{
bUndoIdInitialized = true;
- if( 1 == rTxt.Len() )
+ if( 1 == rTxt.getLength() )
{
rEditSh.StartUndo( UNDO_AUTOCORRECT );
++m_nEndUndoCounter;
@@ -139,12 +139,12 @@ sal_Bool SwAutoCorrDoc::Insert( xub_StrLen nPos, const String& rTxt )
return sal_True;
}
-sal_Bool SwAutoCorrDoc::Replace( xub_StrLen nPos, const String& rTxt )
+sal_Bool SwAutoCorrDoc::Replace( xub_StrLen nPos, const OUString& rTxt )
{
- return ReplaceRange( nPos, rTxt.Len(), rTxt );
+ return ReplaceRange( nPos, rTxt.getLength(), rTxt );
}
-sal_Bool SwAutoCorrDoc::ReplaceRange( xub_StrLen nPos, xub_StrLen nSourceLength, const String& rTxt )
+sal_Bool SwAutoCorrDoc::ReplaceRange( xub_StrLen nPos, xub_StrLen nSourceLength, const OUString& rTxt )
{
SwPaM* pPam = &rCrsr;
if( pPam->GetPoint()->nContent.GetIndex() != nPos )
@@ -161,8 +161,8 @@ sal_Bool SwAutoCorrDoc::ReplaceRange( xub_StrLen nPos, xub_StrLen nSourceLength,
// text attributes with dummy characters must not be replaced!
bool bDoReplace = true;
- xub_StrLen const nLen = rTxt.Len();
- for ( xub_StrLen n = 0; n < nLen; ++n )
+ sal_Int32 const nLen = rTxt.getLength();
+ for ( sal_Int32 n = 0; n < nLen; ++n )
{
sal_Unicode const Char = pNd->GetTxt()[n + nPos];
if ( ( CH_TXTATR_BREAKWORD == Char || CH_TXTATR_INWORD == Char )
@@ -197,7 +197,7 @@ sal_Bool SwAutoCorrDoc::ReplaceRange( xub_StrLen nPos, xub_StrLen nSourceLength,
}
else
{
- if( nSourceLength != rTxt.Len() )
+ if( nSourceLength != rTxt.getLength() )
{
pPam->SetMark();
pPam->GetPoint()->nContent = std::min<sal_Int32>(
@@ -213,7 +213,7 @@ sal_Bool SwAutoCorrDoc::ReplaceRange( xub_StrLen nPos, xub_StrLen nSourceLength,
if( bUndoIdInitialized )
{
bUndoIdInitialized = true;
- if( 1 == rTxt.Len() )
+ if( 1 == rTxt.getLength() )
{
rEditSh.StartUndo( UNDO_AUTOCORRECT );
++m_nEndUndoCounter;
@@ -266,15 +266,13 @@ sal_Bool SwAutoCorrDoc::SetINetAttr( xub_StrLen nStt, xub_StrLen nEnd, const OUS
/** Return the text of a previous paragraph
*
- * This must not be empty!
- *
* @param bAtNormalPos If <true> before the normal insert position; if <false> in which the
* corrected word was inserted. (Doesn't need to be the same paragraph!)
* @return text or 0, if previous paragraph does not exists or there are only blankness
*/
-const String* SwAutoCorrDoc::GetPrevPara( sal_Bool bAtNormalPos )
+OUString SwAutoCorrDoc::GetPrevPara( sal_Bool bAtNormalPos )
{
- const String* pStr = 0;
+ OUString aStr;
if( bAtNormalPos || !pIdx )
pIdx = new SwNodeIndex( rCrsr.GetPoint()->nNode, -1 );
@@ -288,16 +286,16 @@ const String* SwAutoCorrDoc::GetPrevPara( sal_Bool bAtNormalPos )
pTNd = pIdx->GetNode().GetTxtNode();
}
if( pTNd && 0 == pTNd->GetAttrOutlineLevel() )//#outline level,zhaojianwei
- pStr = reinterpret_cast<String const*>(&pTNd->GetTxt()); // FIXME
+ aStr = pTNd->GetTxt();
if( bUndoIdInitialized )
bUndoIdInitialized = true;
- return pStr;
+ return aStr;
}
sal_Bool SwAutoCorrDoc::ChgAutoCorrWord( xub_StrLen & rSttPos, xub_StrLen nEndPos,
- SvxAutoCorrect& rACorrect,
- const String** ppPara )
+ SvxAutoCorrect& rACorrect,
+ OUString* pPara )
{
if( bUndoIdInitialized )
bUndoIdInitialized = true;
@@ -347,7 +345,7 @@ sal_Bool SwAutoCorrDoc::ChgAutoCorrWord( xub_StrLen & rSttPos, xub_StrLen nEndPo
DeleteSel( aPam );
pDoc->DontExpandFmt( *aPam.GetPoint() );
- if( ppPara )
+ if( pPara )
{
OSL_ENSURE( !pIdx, "who has not deleted his Index?" );
pIdx = new SwNodeIndex( rCrsr.GetPoint()->nNode, -1 );
@@ -378,7 +376,7 @@ sal_Bool SwAutoCorrDoc::ChgAutoCorrWord( xub_StrLen & rSttPos, xub_StrLen nEndPo
aExpItem.RestoreDontExpandItems( *aPam.GetPoint() );
- if( ppPara )
+ if( pPara )
{
++(*pIdx);
pTxtNd = pIdx->GetNode().GetTxtNode();
@@ -389,8 +387,8 @@ sal_Bool SwAutoCorrDoc::ChgAutoCorrWord( xub_StrLen & rSttPos, xub_StrLen nEndPo
}
}
- if( bRet && ppPara && pTxtNd )
- *ppPara = reinterpret_cast<String const*>(&pTxtNd->GetTxt()); //FIXME
+ if( bRet && pPara && pTxtNd )
+ *pPara = pTxtNd->GetTxt();
return bRet;
}
@@ -402,7 +400,7 @@ sal_Bool SwAutoCorrDoc::ChgAutoCorrWord( xub_StrLen & rSttPos, xub_StrLen nEndPo
// after the exchange of characters. Then the words, if necessary, can be inserted
// into the exception list.
void SwAutoCorrDoc::SaveCpltSttWord( sal_uLong nFlag, xub_StrLen nPos,
- const String& rExceptWord,
+ const OUString& rExceptWord,
sal_Unicode cChar )
{
sal_uLong nNode = pIdx ? pIdx->GetIndex() : rCrsr.GetPoint()->nNode.GetIndex();
diff --git a/sw/source/core/inc/acorrect.hxx b/sw/source/core/inc/acorrect.hxx
index e0d0bc5c4fe2..a7a5e6b3d152 100644
--- a/sw/source/core/inc/acorrect.hxx
+++ b/sw/source/core/inc/acorrect.hxx
@@ -58,9 +58,9 @@ public:
~SwAutoCorrDoc();
virtual sal_Bool Delete( xub_StrLen nStt, xub_StrLen nEnd );
- virtual sal_Bool Insert( xub_StrLen nPos, const String& rTxt );
- virtual sal_Bool Replace( xub_StrLen nPos, const String& rTxt );
- virtual sal_Bool ReplaceRange( xub_StrLen nPos, xub_StrLen nLen, const String& rTxt );
+ virtual sal_Bool Insert( xub_StrLen nPos, const OUString& rTxt );
+ virtual sal_Bool Replace( xub_StrLen nPos, const OUString& rTxt );
+ virtual sal_Bool ReplaceRange( xub_StrLen nPos, xub_StrLen nLen, const OUString& rTxt );
virtual sal_Bool SetAttr( xub_StrLen nStt, xub_StrLen nEnd, sal_uInt16 nSlotId,
SfxPoolItem& );
@@ -68,23 +68,22 @@ public:
virtual sal_Bool SetINetAttr( xub_StrLen nStt, xub_StrLen nEnd, const OUString& rURL );
// return text of a previous paragraph
- // This must not be empty/blank!
- // If it does not exist or if there is nothing before, return 0.
+ // If it does not exist or if there is nothing before, return blank.
// - sal_True: paragraph before "normal" insertion position
// - sal_False: paragraph in that the corrected word was inserted
// (does not need to be the same paragraph)
- virtual const String* GetPrevPara( sal_Bool bAtNormalPos );
+ virtual OUString GetPrevPara( sal_Bool bAtNormalPos );
virtual sal_Bool ChgAutoCorrWord( xub_StrLen& rSttPos, xub_StrLen nEndPos,
SvxAutoCorrect& rACorrect,
- const String** ppPara );
+ OUString* pPara );
// Will be called after swapping characters by the functions
// - FnCptlSttWrd and
// - FnCptlSttSntnc.
// Afterwards the words can be added into exception list if needed.
virtual void SaveCpltSttWord( sal_uLong nFlag, xub_StrLen nPos,
- const String& rExceptWord, sal_Unicode cChar );
+ const OUString& rExceptWord, sal_Unicode cChar );
virtual LanguageType GetLanguage( xub_StrLen nPos, sal_Bool bPrevPara ) const;
};