diff options
author | Matteo Casalin <matteo.casalin@yahoo.com> | 2013-08-09 22:11:53 +0200 |
---|---|---|
committer | Tor Lillqvist <tml@iki.fi> | 2013-08-13 08:05:41 +0000 |
commit | f4fd558ac9d61fe06aa0f56d829916ef9e5ee7b9 (patch) | |
tree | 02ed54f68b09ee5c05fa932d9f0cfc356c3ea260 /sw/source | |
parent | c083d68d1670b88ad3a88b768859c7bb1c5e5fee (diff) |
String to OUString and some reduction of scope
Change-Id: Ia760c5f3f8c158bea30be3102841a66330e5180a
Reviewed-on: https://gerrit.libreoffice.org/5339
Reviewed-by: Tor Lillqvist <tml@iki.fi>
Tested-by: Tor Lillqvist <tml@iki.fi>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/doc/doctxm.cxx | 54 | ||||
-rw-r--r-- | sw/source/core/tox/tox.cxx | 361 | ||||
-rw-r--r-- | sw/source/core/tox/txmsrt.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/txtnode/atrtox.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/unocore/unoidx.cxx | 6 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8nds.cxx | 4 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8atr.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par5.cxx | 2 | ||||
-rw-r--r-- | sw/source/ui/docvw/edtwin2.cxx | 2 | ||||
-rw-r--r-- | sw/source/ui/index/cnttab.cxx | 53 | ||||
-rw-r--r-- | sw/source/ui/index/swuiidxmrk.cxx | 6 |
11 files changed, 234 insertions, 264 deletions
diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx index 8135874d74ad..08d54716e911 100644 --- a/sw/source/core/doc/doctxm.cxx +++ b/sw/source/core/doc/doctxm.cxx @@ -103,14 +103,12 @@ sal_uInt16 SwDoc::GetTOIKeys( SwTOIKeyType eTyp, std::vector<String>& rArr ) con if ( pMark && pMark->GetpTxtNd() && pMark->GetpTxtNd()->GetNodes().IsDocNodes() ) { - const String* pStr; - if( TOI_PRIMARY == eTyp ) - pStr = &((SwTOXMark*)pItem)->GetPrimaryKey(); - else - pStr = &((SwTOXMark*)pItem)->GetSecondaryKey(); + const OUString sStr = TOI_PRIMARY == eTyp + ? pItem->GetPrimaryKey() + : pItem->GetSecondaryKey(); - if( pStr->Len() ) - rArr.push_back( *pStr ); + if( !sStr.isEmpty() ) + rArr.push_back( sStr ); } } @@ -359,7 +357,7 @@ const SwTOXBaseSection* SwDoc::InsertTableOf( const SwPosition& rPos, // Value of 1st parameter = default value. pNewSection->Update( 0, true ); } - else if( 1 == rTOX.GetTitle().Len() && IsInReading() ) + else if( rTOX.GetTitle().getLength()==1 && IsInReading() ) // insert title of TOX { // then insert the headline section @@ -610,12 +608,12 @@ const SwTOXType* SwDoc::InsertTOXType( const SwTOXType& rTyp ) return pNew; } -String SwDoc::GetUniqueTOXBaseName( const SwTOXType& rType, - const String& rChkStr ) const +OUString SwDoc::GetUniqueTOXBaseName( const SwTOXType& rType, + const OUString sChkStr ) const { - bool bUseChkStr = rChkStr.Len()>0; - String aName( rType.GetTypeName() ); - xub_StrLen nNmLen = aName.Len(); + bool bUseChkStr = !sChkStr.isEmpty(); + const OUString aName( rType.GetTypeName() ); + const sal_Int32 nNmLen = aName.getLength(); sal_uInt16 nNum = 0; const sal_uInt16 nFlagSize = ( mpSectionFmtTbl->size() / 8 ) +2; @@ -631,15 +629,15 @@ String SwDoc::GetUniqueTOXBaseName( const SwTOXType& rType, const SwSection& rSect = pSectNd->GetSection(); if (rSect.GetType()==TOX_CONTENT_SECTION) { - const String& rNm = rSect.GetSectionName(); - if( rNm.Match( aName ) == nNmLen ) + const OUString rNm = rSect.GetSectionName(); + if ( aName.startsWith(rNm) ) { // Calculate number and set the Flag - nNum = (sal_uInt16)rNm.Copy( nNmLen ).ToInt32(); + nNum = (sal_uInt16)rNm.copy( nNmLen ).toInt32(); if( nNum-- && nNum < mpSectionFmtTbl->size() ) pSetFlags[ nNum / 8 ] |= (0x01 << ( nNum & 0x07 )); } - if( bUseChkStr && rChkStr.Equals( rNm ) ) + if ( bUseChkStr && sChkStr==rNm ) bUseChkStr = false; } } @@ -666,8 +664,8 @@ String SwDoc::GetUniqueTOXBaseName( const SwTOXType& rType, } delete [] pSetFlags; if ( bUseChkStr ) - return rChkStr; - return aName += OUString::number( ++nNum ); + return sChkStr; + return aName + OUString::number( ++nNum ); } bool SwDoc::SetTOXBaseName(const SwTOXBase& rTOXBase, const String& rName) @@ -879,7 +877,7 @@ void SwTOXBaseSection::Update(const SfxItemSet* pAttr, } // insert title of TOX - if( GetTitle().Len() ) + if ( !GetTitle().isEmpty() ) { // then insert the headline section SwNodeIndex aIdx( *pSectNd, +1 ); @@ -924,7 +922,7 @@ void SwTOXBaseSection::Update(const SfxItemSet* pAttr, (TOX_ILLUSTRATIONS == SwTOXBase::GetType() && IsFromObjectNames())) UpdateCntnt( nsSwTOXElement::TOX_GRAPHIC, pOwnChapterNode ); - if( GetSequenceName().Len() && !IsFromObjectNames() && + if( !GetSequenceName().isEmpty() && !IsFromObjectNames() && (TOX_TABLES == SwTOXBase::GetType() || TOX_ILLUSTRATIONS == SwTOXBase::GetType() ) ) UpdateSequence( pOwnChapterNode ); @@ -998,7 +996,7 @@ void SwTOXBaseSection::Update(const SfxItemSet* pAttr, // Task 70995 - save and restore PageDesc and Break Attributes if( pFirstEmptyNd->HasSwAttrSet() ) { - if( GetTitle().Len() ) + if( !GetTitle().isEmpty() ) aEndIdx = *pSectNd; else aEndIdx = *pFirstEmptyNd; @@ -1162,12 +1160,12 @@ void SwTOXBaseSection::UpdateMarks( const SwTOXInternational& rIntl, GetOptions(), FORM_ENTRY, rIntl, aLocale ); InsertSorted(pBase); if(GetOptions() & nsSwTOIOptions::TOI_KEY_AS_ENTRY && - pTxtMark->GetTOXMark().GetPrimaryKey().Len()) + !pTxtMark->GetTOXMark().GetPrimaryKey().isEmpty()) { pBase = new SwTOXIndex( *pTOXSrc, pTxtMark, GetOptions(), FORM_PRIMARY_KEY, rIntl, aLocale ); InsertSorted(pBase); - if(pTxtMark->GetTOXMark().GetSecondaryKey().Len()) + if (!pTxtMark->GetTOXMark().GetSecondaryKey().isEmpty()) { pBase = new SwTOXIndex( *pTOXSrc, pTxtMark, GetOptions(), FORM_SECONDARY_KEY, rIntl, aLocale ); @@ -1826,7 +1824,7 @@ void SwTOXBaseSection::GenerateText( sal_uInt16 nArrayIdx, case TOKEN_END: break; } - if( aToken.sCharStyleName.Len() ) + if ( !aToken.sCharStyleName.isEmpty() ) { SwCharFmt* pCharFmt; if( USHRT_MAX != aToken.nPoolId ) @@ -2115,7 +2113,7 @@ void SwTOXBaseSection::_UpdatePageNum( SwTxtNode* pNd, } // The main entries should get their character style - if(pCharStyleIdx && !pCharStyleIdx->empty() && GetMainEntryCharStyle().Len()) + if(pCharStyleIdx && !pCharStyleIdx->empty() && !GetMainEntryCharStyle().isEmpty()) { // eventually the last index must me appended if(pCharStyleIdx->size()&0x01) @@ -2155,13 +2153,13 @@ void SwTOXBaseSection::InsertSorted(SwTOXSortTabBase* pNew) // Evaluate Key // Calculate the range where to insert if( 0 == (GetOptions() & nsSwTOIOptions::TOI_KEY_AS_ENTRY) && - rMark.GetPrimaryKey().Len() ) + !rMark.GetPrimaryKey().isEmpty() ) { aRange = GetKeyRange( rMark.GetPrimaryKey(), rMark.GetPrimaryKeyReading(), *pNew, FORM_PRIMARY_KEY, aRange ); - if( rMark.GetSecondaryKey().Len() ) + if( !rMark.GetSecondaryKey().isEmpty() ) aRange = GetKeyRange( rMark.GetSecondaryKey(), rMark.GetSecondaryKeyReading(), *pNew, FORM_SECONDARY_KEY, aRange ); diff --git a/sw/source/core/tox/tox.cxx b/sw/source/core/tox/tox.cxx index 4c6872dc7507..1a469d0aefd4 100644 --- a/sw/source/core/tox/tox.cxx +++ b/sw/source/core/tox/tox.cxx @@ -18,7 +18,6 @@ */ -#include <comphelper/string.hxx> #include <tools/resid.hxx> #include <hintids.hxx> #include <swtypes.hxx> @@ -39,28 +38,8 @@ using namespace std; -const sal_Char* SwForm::aFormEntry = "<E>"; -const sal_Char* SwForm::aFormTab = "<T>"; -const sal_Char* SwForm::aFormPageNums = "<#>"; -const sal_Char* SwForm::aFormLinkStt = "<LS>"; -const sal_Char* SwForm::aFormLinkEnd = "<LE>"; -const sal_Char* SwForm::aFormEntryNum = "<E#>"; -const sal_Char* SwForm::aFormEntryTxt = "<ET>"; -const sal_Char* SwForm::aFormChapterMark= "<C>"; -const sal_Char* SwForm::aFormText = "<X>"; -const sal_Char* SwForm::aFormAuth = "<A>"; -sal_uInt8 SwForm::nFormTabLen = 3; -sal_uInt8 SwForm::nFormEntryLen = 3; -sal_uInt8 SwForm::nFormPageNumsLen = 3; -sal_uInt8 SwForm::nFormLinkSttLen = 4; -sal_uInt8 SwForm::nFormLinkEndLen = 4; -sal_uInt8 SwForm::nFormEntryNumLen = 4; -sal_uInt8 SwForm::nFormEntryTxtLen = 4; -sal_uInt8 SwForm::nFormChapterMarkLen = 3; -sal_uInt8 SwForm::nFormTextLen = 3; -sal_uInt8 SwForm::nFormAuthLen = 5; - -TYPEINIT2( SwTOXMark, SfxPoolItem, SwClient ); // fuers rtti +namespace +{ struct PatternIni { @@ -143,6 +122,11 @@ static SwFormTokens lcl_GetAuthPattern(sal_uInt16 nTypeId) return aRet; } + +} + +TYPEINIT2( SwTOXMark, SfxPoolItem, SwClient ); // fuers rtti + /*-------------------------------------------------------------------- TOX dtor and ctor --------------------------------------------------------------------*/ @@ -227,22 +211,23 @@ void SwTOXMark::InvalidateTOXMark() NotifyClients(&aMsgHint, &aMsgHint); } -String SwTOXMark::GetText() const +OUString SwTOXMark::GetText() const { - String aStr; - if( aAltText.Len() ) - aStr = aAltText; - else if( pTxtAttr && pTxtAttr->GetpTxtNd() ) + if( !aAltText.isEmpty() ) + return aAltText; + + if( pTxtAttr && pTxtAttr->GetpTxtNd() ) { xub_StrLen* pEndIdx = pTxtAttr->GetEnd(); OSL_ENSURE( pEndIdx, "TOXMark without mark!"); if( pEndIdx ) { const xub_StrLen nStt = *pTxtAttr->GetStart(); - aStr = pTxtAttr->GetpTxtNd()->GetExpandTxt( nStt, *pEndIdx-nStt ); + return pTxtAttr->GetpTxtNd()->GetExpandTxt( nStt, *pEndIdx-nStt ); } } - return aStr; + + return OUString(); } void SwTOXMark::InsertTOXMarks( SwTOXMarks& aMarks, const SwTOXType& rType ) @@ -261,7 +246,7 @@ void SwTOXMark::InsertTOXMarks( SwTOXMarks& aMarks, const SwTOXType& rType ) Manage types of TOX --------------------------------------------------------------------*/ -SwTOXType::SwTOXType( TOXTypes eTyp, const String& rName ) +SwTOXType::SwTOXType( TOXTypes eTyp, const OUString& rName ) : SwModify(0), aName(rName), eType(eTyp) @@ -313,7 +298,7 @@ SwForm::SwForm( TOXTypes eTyp ) // #i21237# if (TOX_CONTENT == eType || TOX_ILLUSTRATIONS == eType ) { SwFormToken aLinkStt (TOKEN_LINK_START); - aLinkStt.sCharStyleName = String(SW_RES(STR_POOLCHR_TOXJUMP)); + aLinkStt.sCharStyleName = SW_RES(STR_POOLCHR_TOXJUMP); aTokens.push_back(aLinkStt); } @@ -433,7 +418,7 @@ void SwForm::AdjustTabStops(SwDoc& rDoc, sal_Bool bInsertNewTapStops) // #i21237 { for(sal_uInt16 nLevel = 1; nLevel < GetFormMax(); nLevel++) { - const String& sTemplateName = GetTemplate(nLevel); + const OUString sTemplateName = GetTemplate(nLevel); SwTxtFmtColl* pColl = rDoc.FindTxtFmtCollByName( sTemplateName ); if( !pColl ) @@ -502,13 +487,25 @@ void SwForm::AdjustTabStops(SwDoc& rDoc, sal_Bool bInsertNewTapStops) // #i21237 } } } + +OUString SwForm::GetFormEntry() {return OUString("<E>");} +OUString SwForm::GetFormTab() {return OUString("<T>");} +OUString SwForm::GetFormPageNums() {return OUString("<#>");} +OUString SwForm::GetFormLinkStt() {return OUString("<LS>");} +OUString SwForm::GetFormLinkEnd() {return OUString("<LE>");} +OUString SwForm::GetFormEntryNum() {return OUString("<E#>");} +OUString SwForm::GetFormEntryTxt() {return OUString("<ET>");} +OUString SwForm::GetFormChapterMark() {return OUString("<C>");} +OUString SwForm::GetFormText() {return OUString("<X>");} +OUString SwForm::GetFormAuth() {return OUString("<A>");} + /*-------------------------------------------------------------------- Ctor TOXBase --------------------------------------------------------------------*/ SwTOXBase::SwTOXBase(const SwTOXType* pTyp, const SwForm& rForm, - sal_uInt16 nCreaType, const String& rTitle ) + sal_uInt16 nCreaType, const OUString& rTitle ) : SwClient((SwModify*)pTyp), aForm(rForm), aTitle(rTitle), @@ -599,7 +596,7 @@ SwTOXBase::~SwTOXBase() // delete aData.pTemplateName; } -void SwTOXBase::SetTitle(const String& rTitle) +void SwTOXBase::SetTitle(const OUString& rTitle) { aTitle = rTitle; } @@ -629,119 +626,100 @@ SwTOXBase & SwTOXBase::operator = (const SwTOXBase & rSource) return *this; } -String SwFormToken::GetString() const +OUString SwFormToken::GetString() const { - String sRet; + OUString sToken; - bool bAppend = true; switch( eTokenType ) { case TOKEN_ENTRY_NO: - sRet.AssignAscii( SwForm::aFormEntryNum ); + sToken = SwForm::GetFormEntryNum(); break; case TOKEN_ENTRY_TEXT: - sRet.AssignAscii( SwForm::aFormEntryTxt ); + sToken = SwForm::GetFormEntryTxt(); break; case TOKEN_ENTRY: - sRet.AssignAscii( SwForm::aFormEntry ); + sToken = SwForm::GetFormEntry(); break; case TOKEN_TAB_STOP: - sRet.AssignAscii( SwForm::aFormTab ); + sToken = SwForm::GetFormTab(); break; case TOKEN_TEXT: - sRet.AssignAscii( SwForm::aFormText ); + // Return a Token only if Text is not empty! + if( sText.isEmpty() ) + { + return OUString(); + } + sToken = SwForm::GetFormText(); break; case TOKEN_PAGE_NUMS: - sRet.AssignAscii( SwForm::aFormPageNums ); + sToken = SwForm::GetFormPageNums(); break; case TOKEN_CHAPTER_INFO: - sRet.AssignAscii( SwForm::aFormChapterMark ); + sToken = SwForm::GetFormChapterMark(); break; case TOKEN_LINK_START: - sRet.AssignAscii( SwForm::aFormLinkStt ); + sToken = SwForm::GetFormLinkStt(); break; case TOKEN_LINK_END: - sRet.AssignAscii( SwForm::aFormLinkEnd ); + sToken = SwForm::GetFormLinkEnd(); break; case TOKEN_AUTHORITY: { - sRet.AssignAscii( SwForm::aFormAuth ); - String sTmp( OUString::number( nAuthorityField )); - if( sTmp.Len() < 2 ) - sTmp.Insert('0', 0); - sRet.Insert( sTmp, 2 ); + sToken = SwForm::GetFormAuth(); } break; case TOKEN_END: break; } - sRet.Erase( sRet.Len() - 1 ); - sRet += ' '; - sRet += sCharStyleName; - sRet += ','; - sRet += OUString::number( nPoolId ); - sRet += ','; - // TabStopPosition and TabAlign or ChapterInfoFormat - if(TOKEN_TAB_STOP == eTokenType) - { - sRet += OUString::number( nTabStopPosition ); - sRet += ','; - sRet += OUString::number( static_cast< sal_Int32 >(eTabAlign) ); - sRet += ','; - sRet += cTabFillChar; - sRet += ','; - sRet += OUString::number( bWithTab ); - } - else if(TOKEN_CHAPTER_INFO == eTokenType) - { - sRet += OUString::number( nChapterFormat ); - // add maximum permitted level - sRet += ','; - sRet += OUString::number( nOutlineLevel ); - } - else if(TOKEN_TEXT == eTokenType) - { - //append Text if Len() > 0 only! - if( sText.Len() ) - { - sRet += TOX_STYLE_DELIMITER; - String sTmp(comphelper::string::remove(sText, TOX_STYLE_DELIMITER)); - sRet += sTmp; - sRet += TOX_STYLE_DELIMITER; - } - else - bAppend = false; - } - else if(TOKEN_ENTRY_NO == eTokenType) - { - sRet += OUString::number( nChapterFormat ); - // add maximum permitted level - sRet += ','; - sRet += OUString::number( nOutlineLevel ); - } + OUString sData = " " + sCharStyleName + "," + OUString::number( nPoolId ) + ","; - if(bAppend) - { - sRet += '>'; - } - else + // TabStopPosition and TabAlign or ChapterInfoFormat + switch (eTokenType) { - // don't append empty text tokens - sRet.Erase(); + case TOKEN_TAB_STOP: + sData += OUString::number( nTabStopPosition ) + "," + + OUString::number( static_cast< sal_Int32 >(eTabAlign) ) + "," + + OUString(cTabFillChar) + "," + + OUString::number( bWithTab ); + break; + case TOKEN_CHAPTER_INFO: + case TOKEN_ENTRY_NO: + // add also maximum permitted level + sData += OUString::number( nChapterFormat ) + "," + + OUString::number( nOutlineLevel ); + break; + case TOKEN_TEXT: + sData += OUString(TOX_STYLE_DELIMITER) + + sText.replaceAll(OUString(TOX_STYLE_DELIMITER), OUString()) + + OUString(TOX_STYLE_DELIMITER); + break; + case TOKEN_AUTHORITY: + if (nAuthorityField<10) + { + sData = "0" + OUString::number( nAuthorityField ) + sData; + } + else + { + sData = OUString::number( nAuthorityField ) + sData; + } + default: + break; } - return sRet; + return sToken.copy(0, sToken.getLength()-1) + sData + sToken.copy(sToken.getLength()-1); } // -> #i21237# -SwFormTokensHelper::SwFormTokensHelper(const String & rPattern) +SwFormTokensHelper::SwFormTokensHelper(const OUString & rPattern) { - xub_StrLen nCurPatternPos = 0; - xub_StrLen nCurPatternLen = 0; + sal_Int32 nCurPatternPos = 0; + sal_Int32 nCurPatternLen = 0; - while (nCurPatternPos < rPattern.Len()) + while (nCurPatternPos < rPattern.getLength()) { + // FIXME: nCurPatternLen added but set to 0? nCurPatternPos = nCurPatternPos + nCurPatternLen; SwFormToken aToken = BuildToken(rPattern, nCurPatternPos); @@ -749,12 +727,12 @@ SwFormTokensHelper::SwFormTokensHelper(const String & rPattern) } } -SwFormToken SwFormTokensHelper::BuildToken( const String & sPattern, - xub_StrLen & nCurPatternPos ) const +SwFormToken SwFormTokensHelper::BuildToken( const OUString & sPattern, + sal_Int32 & nCurPatternPos ) const { - String sToken( SearchNextToken(sPattern, nCurPatternPos) ); - nCurPatternPos = nCurPatternPos + sToken.Len(); - xub_StrLen nTokenLen; + OUString sToken( SearchNextToken(sPattern, nCurPatternPos) ); + nCurPatternPos += sToken.getLength(); + sal_Int32 nTokenLen = 0; FormTokenType eTokenType = GetTokenType(sToken, &nTokenLen); // at this point sPattern contains the @@ -762,34 +740,38 @@ SwFormToken SwFormTokensHelper::BuildToken( const String & sPattern, // the form is: CharStyleName, PoolId[, TabStopPosition|ChapterInfoFormat[, TabStopAlignment[, TabFillChar]]] // in text tokens the form differs from the others: CharStyleName, PoolId[,\0xffinserted text\0xff] SwFormToken eRet( eTokenType ); - String sAuthFieldEnum = sToken.Copy( 2, 2 ); - sToken = sToken.Copy( nTokenLen, sToken.Len() - nTokenLen - 1); + const OUString sAuthFieldEnum = sToken.copy( 2, 2 ); + sToken = sToken.copy( nTokenLen, sToken.getLength() - nTokenLen - 1); - eRet.sCharStyleName = sToken.GetToken( 0, ','); - String sTmp( sToken.GetToken( 1, ',' )); - if( sTmp.Len() ) - eRet.nPoolId = static_cast<sal_uInt16>(sTmp.ToInt32()); + eRet.sCharStyleName = sToken.getToken( 0, ','); + OUString sTmp( sToken.getToken( 1, ',' )); + if( !sTmp.isEmpty() ) + eRet.nPoolId = static_cast<sal_uInt16>(sTmp.toInt32()); switch( eTokenType ) { //i53420 + case TOKEN_CHAPTER_INFO: +//i53420 case TOKEN_ENTRY_NO: - if( (sTmp = sToken.GetToken( 2, ',' ) ).Len() ) - eRet.nChapterFormat = static_cast<sal_uInt16>(sTmp.ToInt32()); - if( (sTmp = sToken.GetToken( 3, ',' ) ).Len() ) - eRet.nOutlineLevel = static_cast<sal_uInt16>(sTmp.ToInt32()); //the maximum outline level to examine + sTmp = sToken.getToken( 2, ',' ); + if( !sTmp.isEmpty() ) + eRet.nChapterFormat = static_cast<sal_uInt16>(sTmp.toInt32()); + sTmp = sToken.getToken( 3, ',' ); + if( !sTmp.isEmpty() ) + eRet.nOutlineLevel = static_cast<sal_uInt16>(sTmp.toInt32()); //the maximum outline level to examine break; case TOKEN_TEXT: { - xub_StrLen nStartText = sToken.Search( TOX_STYLE_DELIMITER ); - if( STRING_NOTFOUND != nStartText ) + const sal_Int32 nStartText = sToken.indexOf( TOX_STYLE_DELIMITER ); + if( nStartText>=0 && nStartText+1<sToken.getLength()) { - xub_StrLen nEndText = sToken.Search( TOX_STYLE_DELIMITER, - nStartText + 1); - if( STRING_NOTFOUND != nEndText ) + const sal_Int32 nEndText = sToken.indexOf( TOX_STYLE_DELIMITER, + nStartText + 1); + if( nEndText>=0 ) { - eRet.sText = sToken.Copy( nStartText + 1, + eRet.sText = sToken.copy( nStartText + 1, nEndText - nStartText - 1); } } @@ -797,109 +779,99 @@ SwFormToken SwFormTokensHelper::BuildToken( const String & sPattern, break; case TOKEN_TAB_STOP: - if( (sTmp = sToken.GetToken( 2, ',' ) ).Len() ) - eRet.nTabStopPosition = sTmp.ToInt32(); - - if( (sTmp = sToken.GetToken( 3, ',' ) ).Len() ) - eRet.eTabAlign = static_cast<SvxTabAdjust>(sTmp.ToInt32()); + sTmp = sToken.getToken( 2, ',' ); + if( !sTmp.isEmpty() ) + eRet.nTabStopPosition = sTmp.toInt32(); - if( (sTmp = sToken.GetToken( 4, ',' ) ).Len() ) - eRet.cTabFillChar = sTmp.GetChar(0); + sTmp = sToken.getToken( 3, ',' ); + if( !sTmp.isEmpty() ) + eRet.eTabAlign = static_cast<SvxTabAdjust>(sTmp.toInt32()); - if( (sTmp = sToken.GetToken( 5, ',' ) ).Len() ) - eRet.bWithTab = 0 != sTmp.ToInt32(); - break; - - case TOKEN_CHAPTER_INFO: - if( (sTmp = sToken.GetToken( 2, ',' ) ).Len() ) - eRet.nChapterFormat = static_cast<sal_uInt16>(sTmp.ToInt32()); //SwChapterFormat; - //i53420 - if( (sTmp = sToken.GetToken( 3, ',' ) ).Len() ) - eRet.nOutlineLevel = static_cast<sal_uInt16>(sTmp.ToInt32()); //the maximum outline level to examine + sTmp = sToken.getToken( 4, ',' ); + if( !sTmp.isEmpty() ) + eRet.cTabFillChar = sTmp[0]; + sTmp = sToken.getToken( 5, ',' ); + if( !sTmp.isEmpty() ) + eRet.bWithTab = 0 != sTmp.toInt32(); break; case TOKEN_AUTHORITY: - eRet.nAuthorityField = static_cast<sal_uInt16>(sAuthFieldEnum.ToInt32()); + eRet.nAuthorityField = static_cast<sal_uInt16>(sAuthFieldEnum.toInt32()); break; default: break; } return eRet; } -String SwFormTokensHelper::SearchNextToken( const String & sPattern, - xub_StrLen nStt ) const +OUString SwFormTokensHelper::SearchNextToken( const OUString & sPattern, + sal_Int32 nStt ) const { //it's not so easy - it doesn't work if the text part contains a '>' - //sal_uInt16 nTokenEnd = sPattern.Search('>'); - String aResult; - - xub_StrLen nEnd = sPattern.Search( '>', nStt ); - if( STRING_NOTFOUND == nEnd ) + sal_Int32 nEnd = sPattern.indexOf( '>', nStt ); + if( nEnd<0 ) { - nEnd = sPattern.Len(); + // FIXME: why is nEnd updated? + // should "aResult = sPattern.copy( nStt, nEnd - nStt );" + // or something like that be returned? + nEnd = sPattern.getLength(); } else { - xub_StrLen nTextSeparatorFirst = sPattern.Search( TOX_STYLE_DELIMITER, nStt ); - if( STRING_NOTFOUND != nTextSeparatorFirst ) + const sal_Int32 nTextSeparatorFirst = sPattern.indexOf( TOX_STYLE_DELIMITER, nStt ); + if( nTextSeparatorFirst>=0 && nTextSeparatorFirst+1<sPattern.getLength()) { - xub_StrLen nTextSeparatorSecond = sPattern.Search( TOX_STYLE_DELIMITER, - nTextSeparatorFirst + 1 ); - if( STRING_NOTFOUND != nTextSeparatorSecond && - nEnd > nTextSeparatorFirst ) - nEnd = sPattern.Search( '>', nTextSeparatorSecond ); + const sal_Int32 nTextSeparatorSecond = sPattern.indexOf( TOX_STYLE_DELIMITER, + nTextSeparatorFirst + 1 ); + // Since nEnd>=0 we don't need to check if nTextSeparatorSecond<0! + if( nEnd < nTextSeparatorSecond ) + nEnd = sPattern.indexOf( '>', nTextSeparatorSecond ); + // FIXME: No check to verify that nEnd is still >=0? } ++nEnd; - aResult = sPattern.Copy( nStt, nEnd - nStt ); + return sPattern.copy( nStt, nEnd - nStt ); } - return aResult; + return OUString(); } -FormTokenType SwFormTokensHelper::GetTokenType(const String & sToken, - xub_StrLen * pTokenLen) const +FormTokenType SwFormTokensHelper::GetTokenType(const OUString & sToken, + sal_Int32 * pTokenLen) const { static struct { - const sal_Char* pNm; - sal_uInt16 nLen; + OUString sNm; sal_uInt16 nOffset; FormTokenType eToken; } const aTokenArr[] = { - { SwForm::aFormTab, SwForm::nFormEntryLen, 1, TOKEN_TAB_STOP }, - { SwForm::aFormPageNums, SwForm::nFormPageNumsLen, 1, TOKEN_PAGE_NUMS }, - { SwForm::aFormLinkStt, SwForm::nFormLinkSttLen, 1, TOKEN_LINK_START }, - { SwForm::aFormLinkEnd, SwForm::nFormLinkEndLen, 1, TOKEN_LINK_END }, - { SwForm::aFormEntryNum, SwForm::nFormEntryNumLen, 1, TOKEN_ENTRY_NO }, - { SwForm::aFormEntryTxt, SwForm::nFormEntryTxtLen, 1, TOKEN_ENTRY_TEXT }, - { SwForm::aFormChapterMark,SwForm::nFormChapterMarkLen,1,TOKEN_CHAPTER_INFO }, - { SwForm::aFormText, SwForm::nFormTextLen, 1, TOKEN_TEXT }, - { SwForm::aFormEntry, SwForm::nFormEntryLen, 1, TOKEN_ENTRY }, - { SwForm::aFormAuth, SwForm::nFormAuthLen, 3, TOKEN_AUTHORITY }, - { 0, 0, 0, TOKEN_END } + { SwForm::GetFormTab(), 1, TOKEN_TAB_STOP }, + { SwForm::GetFormPageNums(), 1, TOKEN_PAGE_NUMS }, + { SwForm::GetFormLinkStt(), 1, TOKEN_LINK_START }, + { SwForm::GetFormLinkEnd(), 1, TOKEN_LINK_END }, + { SwForm::GetFormEntryNum(), 1, TOKEN_ENTRY_NO }, + { SwForm::GetFormEntryTxt(), 1, TOKEN_ENTRY_TEXT }, + { SwForm::GetFormChapterMark(), 1, TOKEN_CHAPTER_INFO }, + { SwForm::GetFormText(), 1, TOKEN_TEXT }, + { SwForm::GetFormEntry(), 1, TOKEN_ENTRY }, + { SwForm::GetFormAuth(), 3, TOKEN_AUTHORITY } }; - FormTokenType eTokenType = TOKEN_TEXT; - xub_StrLen nTokenLen = 0; - const sal_Char* pNm; - for( int i = 0; 0 != ( pNm = aTokenArr[ i ].pNm ); ++i ) - if( COMPARE_EQUAL == sToken.CompareToAscii( pNm, - aTokenArr[ i ].nLen - aTokenArr[ i ].nOffset )) + for( size_t i = 0; i<SAL_N_ELEMENTS(aTokenArr); ++i ) + { + const sal_Int32 nLen(aTokenArr[i].sNm.getLength()); + if( sToken.startsWith( aTokenArr[i].sNm.copy(0, nLen - aTokenArr[i].nOffset) )) { - eTokenType = aTokenArr[ i ].eToken; - nTokenLen = aTokenArr[ i ].nLen; - break; + if (pTokenLen) + *pTokenLen = nLen; + return aTokenArr[ i ].eToken; } + } - OSL_ENSURE( pNm, "wrong token" ); - if (pTokenLen) - *pTokenLen = nTokenLen; - - return eTokenType; + OSL_FAIL( "wrong token" ); + return TOKEN_END; } // <- #i21237# @@ -910,7 +882,7 @@ void SwForm::SetPattern(sal_uInt16 nLevel, const SwFormTokens& rTokens) aPattern[nLevel] = rTokens; } -void SwForm::SetPattern(sal_uInt16 nLevel, const String & rStr) +void SwForm::SetPattern(sal_uInt16 nLevel, const OUString & rStr) { OSL_ENSURE(nLevel < GetFormMax(), "Index >= FORM_MAX"); @@ -935,4 +907,5 @@ SwTOXTypes::~SwTOXTypes() for(const_iterator it = begin(); it != end(); ++it) delete *it; } + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/tox/txmsrt.cxx b/sw/source/core/tox/txmsrt.cxx index b0a060a83cbc..7ead4744d2a7 100644 --- a/sw/source/core/tox/txmsrt.cxx +++ b/sw/source/core/tox/txmsrt.cxx @@ -442,10 +442,10 @@ sal_uInt16 SwTOXIndex::GetLevel() const sal_uInt16 nForm = FORM_PRIMARY_KEY; if( 0 == (GetOptions() & nsSwTOIOptions::TOI_KEY_AS_ENTRY)&& - pTxtMark->GetTOXMark().GetPrimaryKey().Len() ) + !pTxtMark->GetTOXMark().GetPrimaryKey().isEmpty() ) { nForm = FORM_SECONDARY_KEY; - if( pTxtMark->GetTOXMark().GetSecondaryKey().Len() ) + if( !pTxtMark->GetTOXMark().GetSecondaryKey().isEmpty() ) nForm = FORM_ENTRY; } return nForm; diff --git a/sw/source/core/txtnode/atrtox.cxx b/sw/source/core/txtnode/atrtox.cxx index 24277cc4cb8a..0c60b94fc6c2 100644 --- a/sw/source/core/txtnode/atrtox.cxx +++ b/sw/source/core/txtnode/atrtox.cxx @@ -30,7 +30,7 @@ SwTxtTOXMark::SwTxtTOXMark( SwTOXMark& rAttr, , m_pEnd( 0 ) { rAttr.pTxtAttr = this; - if ( !rAttr.GetAlternativeText().Len() ) + if ( rAttr.GetAlternativeText().isEmpty() ) { m_nEnd = *pEnd; m_pEnd = & m_nEnd; @@ -58,7 +58,7 @@ void SwTxtTOXMark::CopyTOXMark( SwDoc* pDoc ) TOXTypes eType = rTOX.GetTOXType()->GetType(); sal_uInt16 nCount = pDoc->GetTOXTypeCount( eType ); const SwTOXType* pType = 0; - const XubString& rNm = rTOX.GetTOXType()->GetTypeName(); + const OUString rNm = rTOX.GetTOXType()->GetTypeName(); // kein entsprechender Verzeichnistyp vorhanden -> anlegen // sonst verwenden diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index b237a7ec865b..0dad7574ecb8 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -120,7 +120,7 @@ lcl_ReAssignTOXType(SwDoc* pDoc, SwTOXBase& rTOXBase, const OUString& rNewName) for(sal_uInt16 nUser = 0; nUser < nUserCount; nUser++) { const SwTOXType* pType = pDoc->GetTOXType( TOX_USER, nUser ); - if(pType->GetTypeName().Equals((String)rNewName)) + if (pType->GetTypeName()==rNewName) { pNewType = pType; break; @@ -1915,7 +1915,7 @@ void SwXDocumentIndexMark::Impl::InsertTOXMark( UnoActionContext aAction(pDoc); bool bMark = *rPam.GetPoint() != *rPam.GetMark(); // n.b.: toxmarks must have either alternative text or an extent - if (bMark && rMark.GetAlternativeText().Len()) + if (bMark && !rMark.GetAlternativeText().isEmpty()) { rPam.Normalize(true); rPam.DeleteMark(); @@ -1923,7 +1923,7 @@ void SwXDocumentIndexMark::Impl::InsertTOXMark( } // Marks ohne Alternativtext ohne selektierten Text koennen nicht eingefuegt werden, // deshalb hier ein Leerzeichen - ob das die ideale Loesung ist? - if (!bMark && !rMark.GetAlternativeText().Len()) + if (!bMark && rMark.GetAlternativeText().isEmpty()) { rMark.SetAlternativeText( OUString(' ') ); } diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index f320ce486d09..7af0c2ee3e4f 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -1074,9 +1074,9 @@ void AttributeOutputBase::TOXMark( const SwTxtNode& rNode, const SwTOXMark& rAtt { case TOX_INDEX: eType = ww::eXE; - if ( rAttr.GetPrimaryKey().Len() ) + if ( !rAttr.GetPrimaryKey().isEmpty() ) { - if ( rAttr.GetSecondaryKey().Len() ) + if ( !rAttr.GetSecondaryKey().isEmpty() ) { sTxt.Insert( ':', 0 ); sTxt.Insert( rAttr.GetSecondaryKey(), 0 ); diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 66acee62f413..f79155dbad88 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -1975,7 +1975,7 @@ static int lcl_CheckForm( const SwForm& rForm, sal_uInt8 nLvl, String& rText ) break; case TOKEN_TEXT: nRet = 3; - rText = aIt->sText.Copy( 0, 5 ); // #i21237# + rText = aIt->sText.copy( 0, 5 ); // #i21237# break; case TOKEN_LINK_START: diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx index ed1ef20c16eb..dbae13cff3cb 100644 --- a/sw/source/filter/ww8/ww8par5.cxx +++ b/sw/source/filter/ww8/ww8par5.cxx @@ -2877,7 +2877,7 @@ static void EnsureMaxLevelForTemplates(SwTOXBase& rBase) { for (sal_uInt16 nI = MAXLEVEL; nI > 0; --nI) { - if (rBase.GetStyleNames(nI-1).Len()) + if (!rBase.GetStyleNames(nI-1).isEmpty()) { rBase.SetLevel(nI); break; diff --git a/sw/source/ui/docvw/edtwin2.cxx b/sw/source/ui/docvw/edtwin2.cxx index 644ee08a7531..a96cdc0251a9 100644 --- a/sw/source/ui/docvw/edtwin2.cxx +++ b/sw/source/ui/docvw/edtwin2.cxx @@ -256,7 +256,7 @@ void SwEditWin::RequestHelp(const HelpEvent &rEvt) { const SwTOXType* pTType = aCntntAtPos.pFndTxtAttr-> GetTOXMark().GetTOXType(); - if( pTType && pTType->GetTypeName().Len() ) + if( pTType && !pTType->GetTypeName().isEmpty() ) { sTxt.InsertAscii( ": ", 0 ); sTxt.Insert( pTType->GetTypeName(), 0 ); diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx index b8f552c60867..68482fc680f3 100644 --- a/sw/source/ui/index/cnttab.cxx +++ b/sw/source/ui/index/cnttab.cxx @@ -1730,7 +1730,7 @@ public: OSL_ENSURE(TOKEN_LINK_START == aFormToken.eTokenType, "call SetLinkEnd for link start only!"); aFormToken.eTokenType = TOKEN_LINK_END; - aFormToken.sText.AssignAscii(SwForm::aFormLinkEnd); + aFormToken.sText = SwForm::GetFormLinkEnd(); SetText(aFormToken.sText); } void SetLinkStart() @@ -1738,7 +1738,7 @@ public: OSL_ENSURE(TOKEN_LINK_END == aFormToken.eTokenType, "call SetLinkStart for link start only!"); aFormToken.eTokenType = TOKEN_LINK_START; - aFormToken.sText.AssignAscii(SwForm::aFormLinkStt); + aFormToken.sText = SwForm::GetFormLinkStt(); SetText(aFormToken.sText); } }; @@ -2340,8 +2340,7 @@ IMPL_LINK(SwTOXEntryTabPage, RemoveInsertAuthHdl, PushButton*, pButton) String sToInsert(aAuthFieldsLB.GetSelectEntry()); SwFormToken aInsert(TOKEN_AUTHORITY); aInsert.nAuthorityField = (sal_uInt16)(sal_uIntPtr)aAuthFieldsLB.GetEntryData(nSelPos); - aTokenWIN.InsertAtSelection(OUString::createFromAscii( - SwForm::aFormAuth), aInsert); + aTokenWIN.InsertAtSelection(SwForm::GetFormAuth(), aInsert); aAuthFieldsLB.RemoveEntry(sToInsert); aAuthFieldsLB.SelectEntryPos( nSelPos ? nSelPos - 1 : 0); } @@ -2382,42 +2381,42 @@ IMPL_LINK(SwTOXEntryTabPage, InsertTokenHdl, PushButton*, pBtn) sal_uInt16 nChapterFormat = CF_NUMBER; // i89791 if(pBtn == &aEntryNoPB) { - sText.AssignAscii(SwForm::aFormEntryNum); + sText = SwForm::GetFormEntryNum(); eTokenType = TOKEN_ENTRY_NO; } else if(pBtn == &aEntryPB) { if( TOX_CONTENT == m_pCurrentForm->GetTOXType() ) { - sText.AssignAscii( SwForm::aFormEntryTxt ); + sText = SwForm::GetFormEntryTxt(); eTokenType = TOKEN_ENTRY_TEXT; } else { - sText.AssignAscii( SwForm::aFormEntry); + sText = SwForm::GetFormEntry(); eTokenType = TOKEN_ENTRY; } } else if(pBtn == &aChapterInfoPB) { - sText.AssignAscii( SwForm::aFormChapterMark); + sText = SwForm::GetFormChapterMark(); eTokenType = TOKEN_CHAPTER_INFO; nChapterFormat = CF_NUM_NOPREPST_TITLE; // i89791 } else if(pBtn == &aPageNoPB) { - sText.AssignAscii(SwForm::aFormPageNums); + sText = SwForm::GetFormPageNums(); eTokenType = TOKEN_PAGE_NUMS; } else if(pBtn == &aHyperLinkPB) { - sText.AssignAscii(SwForm::aFormLinkStt); + sText = SwForm::GetFormLinkStt(); eTokenType = TOKEN_LINK_START; sCharStyle = String(SW_RES(STR_POOLCHR_TOXJUMP)); } else if(pBtn == &aTabPB) { - sText.AssignAscii(SwForm::aFormTab); + sText = SwForm::GetFormTab(); eTokenType = TOKEN_TAB_STOP; } SwFormToken aInsert(eTokenType); @@ -2520,7 +2519,7 @@ IMPL_LINK(SwTOXEntryTabPage, SortKeyHdl, RadioButton*, pButton) IMPL_LINK(SwTOXEntryTabPage, TokenSelectedHdl, SwFormToken*, pToken) { - if(pToken->sCharStyleName.Len()) + if (!pToken->sCharStyleName.isEmpty()) aCharStyleLB.SelectEntry(pToken->sCharStyleName); else aCharStyleLB.SelectEntry(sNoCharStyle); @@ -2881,23 +2880,23 @@ void SwTokenWindow::SetForm(SwForm& rForm, sal_uInt16 nL) if(!pSetActiveControl) pSetActiveControl = pCtrl; } - const sal_Char* pTmp = 0; + + OUString sForm; switch( aToken.eTokenType ) { - case TOKEN_ENTRY_NO: pTmp = SwForm::aFormEntryNum; break; - case TOKEN_ENTRY_TEXT: pTmp = SwForm::aFormEntryTxt; break; - case TOKEN_ENTRY: pTmp = SwForm::aFormEntry; break; - case TOKEN_TAB_STOP: pTmp = SwForm::aFormTab; break; - case TOKEN_PAGE_NUMS: pTmp = SwForm::aFormPageNums; break; - case TOKEN_CHAPTER_INFO:pTmp = SwForm::aFormChapterMark; break; - case TOKEN_LINK_START: pTmp = SwForm::aFormLinkStt; break; - case TOKEN_LINK_END: pTmp = SwForm::aFormLinkEnd; break; - case TOKEN_AUTHORITY: pTmp = SwForm::aFormAuth; break; + case TOKEN_ENTRY_NO: sForm = SwForm::GetFormEntryNum(); break; + case TOKEN_ENTRY_TEXT: sForm = SwForm::GetFormEntryTxt(); break; + case TOKEN_ENTRY: sForm = SwForm::GetFormEntry(); break; + case TOKEN_TAB_STOP: sForm = SwForm::GetFormTab(); break; + case TOKEN_PAGE_NUMS: sForm = SwForm::GetFormPageNums(); break; + case TOKEN_CHAPTER_INFO: sForm = SwForm::GetFormChapterMark(); break; + case TOKEN_LINK_START: sForm = SwForm::GetFormLinkStt(); break; + case TOKEN_LINK_END: sForm = SwForm::GetFormLinkEnd(); break; + case TOKEN_AUTHORITY: sForm = SwForm::GetFormAuth(); break; default:; //prevent warning } - InsertItem( pTmp ? OUString::createFromAscii(pTmp) - : OUString(), aToken ); + InsertItem( sForm, aToken ); bLastWasText = false; } @@ -3483,7 +3482,7 @@ sal_Bool SwTokenWindow::CreateQuickHelp(Control* pCtrl, } else { - if(rToken.sCharStyleName.Len()) + if (!rToken.sCharStyleName.isEmpty()) { if(bBalloon) sEntry += '\n'; @@ -3697,7 +3696,7 @@ void SwTOXStylesTabPage::ActivatePage( const SfxItemSet& ) // display 1st TemplateEntry String aStr( SW_RES( STR_TITLE )); - if( m_pCurrentForm->GetTemplate( 0 ).Len() ) + if( !m_pCurrentForm->GetTemplate( 0 ).isEmpty() ) { aStr += ' '; aStr += aDeliStart; @@ -3719,7 +3718,7 @@ void SwTOXStylesTabPage::ActivatePage( const SfxItemSet& ) } String aCpy( aStr ); - if( m_pCurrentForm->GetTemplate( i ).Len() ) + if( !m_pCurrentForm->GetTemplate( i ).isEmpty() ) { aCpy += ' '; aCpy += aDeliStart; diff --git a/sw/source/ui/index/swuiidxmrk.cxx b/sw/source/ui/index/swuiidxmrk.cxx index 1e1d863cc9dd..8c89daf7907e 100644 --- a/sw/source/ui/index/swuiidxmrk.cxx +++ b/sw/source/ui/index/swuiidxmrk.cxx @@ -811,9 +811,9 @@ void SwIndexMarkPane::UpdateDialog() { bLevelEnable = sal_False; bKeyEnable = sal_True; - bKey1HasText = bKey2Enable = 0 != pMark->GetPrimaryKey().Len(); - bKey2HasText = 0 != pMark->GetSecondaryKey().Len(); - bEntryHasText = 0 != pMark->GetText().Len(); + bKey1HasText = bKey2Enable = !pMark->GetPrimaryKey().isEmpty(); + bKey2HasText = !pMark->GetSecondaryKey().isEmpty(); + bEntryHasText = !pMark->GetText().isEmpty(); m_pKey1DCB->SetText( pMark->GetPrimaryKey() ); m_pKey2DCB->SetText( pMark->GetSecondaryKey() ); m_pPhoneticED0->SetText( pMark->GetTextReading() ); |