From 263153842741d7ce21cc0bf1c5296a55a1138024 Mon Sep 17 00:00:00 2001 From: Matteo Casalin Date: Sun, 14 Jul 2013 15:21:18 +0200 Subject: String to OUString MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I64f31d8a0bb02a2ecd8fcc993c90ca76923b35fb Reviewed-on: https://gerrit.libreoffice.org/4924 Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- sw/source/core/crsr/findtxt.cxx | 4 +- sw/source/core/doc/docfld.cxx | 58 +++--- sw/source/core/edit/edattr.cxx | 8 +- sw/source/core/fields/authfld.cxx | 43 ++-- sw/source/core/fields/chpfld.cxx | 67 +++--- sw/source/core/fields/dbfld.cxx | 145 ++++++------- sw/source/core/fields/ddefld.cxx | 95 ++++----- sw/source/core/fields/docufld.cxx | 370 ++++++++++++++++------------------ sw/source/core/fields/expfld.cxx | 272 +++++++++++++------------ sw/source/core/fields/fldbas.cxx | 50 +++-- sw/source/core/fields/flddat.cxx | 2 +- sw/source/core/fields/flddropdown.cxx | 55 ++--- sw/source/core/fields/macrofld.cxx | 45 ++--- sw/source/core/fields/reffld.cxx | 72 ++++--- sw/source/core/fields/scrptfld.cxx | 12 +- sw/source/core/fields/tblcalc.cxx | 53 +++-- sw/source/core/fields/usrfld.cxx | 46 ++--- sw/source/core/inc/docfld.hxx | 4 +- 18 files changed, 687 insertions(+), 714 deletions(-) (limited to 'sw/source/core') diff --git a/sw/source/core/crsr/findtxt.cxx b/sw/source/core/crsr/findtxt.cxx index 6f56e120f50a..8439cffdc13d 100644 --- a/sw/source/core/crsr/findtxt.cxx +++ b/sw/source/core/crsr/findtxt.cxx @@ -134,8 +134,8 @@ static String& lcl_CleanStr( const SwTxtNode& rNd, xub_StrLen nStart, xub_StrLen // replacement and remove afterwards all at a string's // end (might be normal 0x7f). bool bEmpty = RES_TXTATR_FIELD != pHt->Which() || - !(static_cast(pHt) - ->GetFld().GetFld()->ExpandField(true).Len()); + (static_cast(pHt) + ->GetFld().GetFld()->ExpandField(true).isEmpty()); if ( bEmpty && nStart == nAkt ) { rArr.push_back( nAkt ); diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx index a78a59289742..bb7db008fd34 100644 --- a/sw/source/core/doc/docfld.cxx +++ b/sw/source/core/doc/docfld.cxx @@ -984,15 +984,14 @@ _HashStr::_HashStr( const String& rName, const String& rText, } /// Look up the Name, if it is present, return it's String, otherwise return an empty String -void LookString( SwHash** ppTbl, sal_uInt16 nSize, const String& rName, - String& rRet, sal_uInt16* pPos ) +OUString LookString( SwHash** ppTbl, sal_uInt16 nSize, const OUString& rName, + sal_uInt16* pPos ) { - rRet = comphelper::string::strip(rName, ' '); - SwHash* pFnd = Find( rRet, ppTbl, nSize, pPos ); + SwHash* pFnd = Find( comphelper::string::strip(rName, ' '), ppTbl, nSize, pPos ); if( pFnd ) - rRet = ((_HashStr*)pFnd)->aSetStr; - else - rRet.Erase(); + return ((_HashStr*)pFnd)->aSetStr; + + return OUString(); } static String lcl_GetDBVarName( SwDoc& rDoc, SwDBNameInfField& rDBFld ) @@ -1145,8 +1144,7 @@ void SwDoc::FldsToExpand( SwHash**& ppHashTbl, sal_uInt16& rTblSize, // set the new value in the hash table // is the formula a field? SwSetExpField* pSFld = (SwSetExpField*)pFld; - String aNew; - LookString( ppHashTbl, rTblSize, pSFld->GetFormula(), aNew ); + String aNew = LookString( ppHashTbl, rTblSize, pSFld->GetFormula() ); if( !aNew.Len() ) // nothing found, then the formula is aNew = pSFld->GetFormula(); // the new value @@ -1392,8 +1390,8 @@ void SwDoc::UpdateExpFlds( SwTxtFld* pUpdtFld, bool bUpdRefFlds ) if( (!pUpdtFld || pUpdtFld == pTxtFld ) && pGFld->IsInBodyTxt() ) { - LookString( pHashStrTbl, nStrFmtCnt, - pGFld->GetFormula(), aNew ); + aNew = LookString( pHashStrTbl, nStrFmtCnt, + pGFld->GetFormula() ); pGFld->ChgExpStr( aNew ); } } @@ -1401,8 +1399,8 @@ void SwDoc::UpdateExpFlds( SwTxtFld* pUpdtFld, bool bUpdRefFlds ) { SwSetExpField* pSFld = (SwSetExpField*)pFld; // is the "formula" a field? - LookString( pHashStrTbl, nStrFmtCnt, - pSFld->GetFormula(), aNew ); + aNew = LookString( pHashStrTbl, nStrFmtCnt, + pSFld->GetFormula() ); if( !aNew.Len() ) // nothing found then the formula is the new value aNew = pSFld->GetFormula(); @@ -2261,11 +2259,11 @@ void SwDocUpdtFld::_MakeFldList( SwDoc& rDoc, int eGetMode ) } } - OUString sTrue("TRUE"), sFalse("FALSE"); + const OUString sTrue("TRUE"); + const OUString sFalse("FALSE"); bool bIsDBMgr = 0 != rDoc.GetNewDBMgr(); sal_uInt16 nWhich, n; - const OUString* pFormel = 0; const SfxPoolItem* pItem; sal_uInt32 nMaxItems = rDoc.GetAttrPool().GetItemCount2( RES_TXTATR_FIELD ); for( n = 0; n < nMaxItems; ++n ) @@ -2278,40 +2276,41 @@ void SwDocUpdtFld::_MakeFldList( SwDoc& rDoc, int eGetMode ) if( !pTxtFld || !pTxtFld->GetTxtNode().GetNodes().IsDocNodes() ) continue; + OUString sFormel; const SwField* pFld = pFmtFld->GetFld(); switch( nWhich = pFld->GetTyp()->Which() ) { case RES_DBSETNUMBERFLD: case RES_GETEXPFLD: if( GETFLD_ALL == eGetMode ) - pFormel = &sTrue; + sFormel = sTrue; break; case RES_DBFLD: if( GETFLD_EXPAND & eGetMode ) - pFormel = &sTrue; + sFormel = sTrue; break; case RES_SETEXPFLD: if ( !(eGetMode == GETFLD_EXPAND) || (nsSwGetSetExpType::GSE_STRING & pFld->GetSubType()) ) { - pFormel = &sTrue; + sFormel = sTrue; } break; case RES_HIDDENPARAFLD: if( GETFLD_ALL == eGetMode ) { - pFormel = &pFld->GetPar1(); - if (pFormel->isEmpty() || pFormel->equals(sFalse)) + sFormel = pFld->GetPar1(); + if (sFormel.isEmpty() || sFormel==sFalse) ((SwHiddenParaField*)pFld)->SetHidden( sal_False ); - else if (pFormel->equals(sTrue)) + else if (sFormel==sTrue) ((SwHiddenParaField*)pFld)->SetHidden( sal_True ); else break; - pFormel = 0; + sFormel = OUString(); // trigger formatting ((SwFmtFld*)pFmtFld)->ModifyNotification( 0, 0 ); } @@ -2320,15 +2319,15 @@ void SwDocUpdtFld::_MakeFldList( SwDoc& rDoc, int eGetMode ) case RES_HIDDENTXTFLD: if( GETFLD_ALL == eGetMode ) { - pFormel = &pFld->GetPar1(); - if (pFormel->isEmpty() || pFormel->equals(sFalse)) + sFormel = pFld->GetPar1(); + if (sFormel.isEmpty() || sFormel==sFalse) ((SwHiddenTxtField*)pFld)->SetValue( sal_True ); - else if (pFormel->equals(sTrue)) + else if (sFormel==sTrue) ((SwHiddenTxtField*)pFld)->SetValue( sal_False ); else break; - pFormel = 0; + sFormel = OUString(); // evaluate field ((SwHiddenTxtField*)pFld)->Evaluate(&rDoc); @@ -2346,7 +2345,7 @@ void SwDocUpdtFld::_MakeFldList( SwDoc& rDoc, int eGetMode ) (GETFLD_ALL == eGetMode || (GETFLD_CALC & eGetMode && ((SwDBNumSetField*)pFld)->IsCondValid())) ) { - pFormel = &pFld->GetPar1(); + sFormel = pFld->GetPar1(); } } break; @@ -2359,16 +2358,15 @@ void SwDocUpdtFld::_MakeFldList( SwDoc& rDoc, int eGetMode ) (GETFLD_ALL == eGetMode || (GETFLD_CALC & eGetMode && ((SwDBNextSetField*)pFld)->IsCondValid())) ) { - pFormel = &pFld->GetPar1(); + sFormel = pFld->GetPar1(); } } break; } - if (pFormel && !pFormel->isEmpty()) + if (!sFormel.isEmpty()) { GetBodyNode( *pTxtFld, nWhich ); - pFormel = 0; } } nFldLstGetMode = static_cast( eGetMode ); diff --git a/sw/source/core/edit/edattr.cxx b/sw/source/core/edit/edattr.cxx index 74b58a50c44e..1133863f2364 100644 --- a/sw/source/core/edit/edattr.cxx +++ b/sw/source/core/edit/edattr.cxx @@ -346,15 +346,15 @@ sal_uInt16 SwEditShell::GetSeqFtnList( SwSeqFldList& rList, bool bEndNotes ) if( pTxtNd ) { - String sTxt( rFtn.GetViewNumStr( *mpDoc )); - if( sTxt.Len() ) - sTxt += ' '; + OUString sTxt( rFtn.GetViewNumStr( *mpDoc )); + if( !sTxt.isEmpty() ) + sTxt += " "; sTxt += pTxtNd->GetExpandTxt( 0, USHRT_MAX ); _SeqFldLstElem* pNew = new _SeqFldLstElem( sTxt, pTxtFtn->GetSeqRefNo() ); while( rList.InsertSort( pNew ) ) - pNew->sDlgEntry += ' '; + pNew->sDlgEntry += " "; } } } diff --git a/sw/source/core/fields/authfld.cxx b/sw/source/core/fields/authfld.cxx index d1fbe7965e7e..3d13d603301d 100644 --- a/sw/source/core/fields/authfld.cxx +++ b/sw/source/core/fields/authfld.cxx @@ -110,13 +110,13 @@ void SwAuthorityFieldType::RemoveField(sal_IntPtr nHandle) #endif } -sal_IntPtr SwAuthorityFieldType::AddField(const String& rFieldContents) +sal_IntPtr SwAuthorityFieldType::AddField(const OUString& rFieldContents) { sal_IntPtr nRet = 0; SwAuthEntry* pEntry = new SwAuthEntry; for( sal_uInt16 i = 0; i < AUTH_FIELD_END; ++i ) pEntry->SetAuthorField( (ToxAuthorityField)i, - rFieldContents.GetToken( i, TOX_STYLE_DELIMITER )); + rFieldContents.getToken( i, TOX_STYLE_DELIMITER )); for(sal_uInt16 j = 0; j < m_DataArr.size() && pEntry; j++) { @@ -178,7 +178,7 @@ const SwAuthEntry* SwAuthorityFieldType::GetEntryByHandle(sal_IntPtr nHandle) c } void SwAuthorityFieldType::GetAllEntryIdentifiers( - std::vector& rToFill )const + std::vector& rToFill )const { for(sal_uInt16 j = 0; j < m_DataArr.size(); j++) { @@ -188,7 +188,7 @@ void SwAuthorityFieldType::GetAllEntryIdentifiers( } const SwAuthEntry* SwAuthorityFieldType::GetEntryByIdentifier( - const String& rIdentifier)const + const OUString& rIdentifier)const { const SwAuthEntry* pRet = 0; for( sal_uInt16 j = 0; j < m_DataArr.size(); ++j ) @@ -373,7 +373,7 @@ bool SwAuthorityFieldType::QueryValue( Any& rVal, sal_uInt16 nWhichId ) const } break; case FIELD_PROP_PAR3: - rVal <<= OUString(GetSortAlgorithm()); + rVal <<= GetSortAlgorithm(); break; case FIELD_PROP_BOOL1: @@ -416,14 +416,14 @@ bool SwAuthorityFieldType::QueryValue( Any& rVal, sal_uInt16 nWhichId ) const bool SwAuthorityFieldType::PutValue( const Any& rAny, sal_uInt16 nWhichId ) { bool bRet = true; - String sTmp; switch( nWhichId ) { case FIELD_PROP_PAR1: case FIELD_PROP_PAR2: { - ::GetString( rAny, sTmp ); - sal_Unicode uSet = sTmp.GetChar(0); + OUString sTmp; + rAny >>= sTmp; + const sal_Unicode uSet = !sTmp.isEmpty() ? sTmp[0] : 0; if( FIELD_PROP_PAR1 == nWhichId ) m_cPrefix = uSet; else @@ -431,9 +431,12 @@ bool SwAuthorityFieldType::PutValue( const Any& rAny, sal_uInt16 nWhichId ) } break; case FIELD_PROP_PAR3: - SetSortAlgorithm( ::GetString( rAny, sTmp )); + { + OUString sTmp; + rAny >>= sTmp; + SetSortAlgorithm(sTmp); break; - + } case FIELD_PROP_BOOL1: m_bIsSequence = *(sal_Bool*)rAny.getValue(); break; @@ -516,7 +519,7 @@ void SwAuthorityFieldType::SetSortKeys(sal_uInt16 nKeyCount, SwTOXSortKey aKeys[ } SwAuthorityField::SwAuthorityField( SwAuthorityFieldType* pInitType, - const String& rFieldContents ) + const OUString& rFieldContents ) : SwField(pInitType), m_nTempSequencePos( -1 ) { @@ -537,12 +540,12 @@ SwAuthorityField::~SwAuthorityField() ((SwAuthorityFieldType* )GetTyp())->RemoveField(m_nHandle); } -String SwAuthorityField::Expand() const +OUString SwAuthorityField::Expand() const { SwAuthorityFieldType* pAuthType = (SwAuthorityFieldType*)GetTyp(); - String sRet; + OUString sRet; if(pAuthType->GetPrefix()) - sRet.Assign(pAuthType->GetPrefix()); + sRet = OUString(pAuthType->GetPrefix()); if( pAuthType->IsSequence() ) { @@ -559,7 +562,7 @@ String SwAuthorityField::Expand() const sRet += pEntry->GetAuthorField(AUTH_FIELD_IDENTIFIER); } if(pAuthType->GetSuffix()) - sRet += pAuthType->GetSuffix(); + sRet += OUString(pAuthType->GetSuffix()); return sRet; } @@ -569,7 +572,7 @@ SwField* SwAuthorityField::Copy() const return new SwAuthorityField(pAuthType, m_nHandle); } -const String& SwAuthorityField::GetFieldText(ToxAuthorityField eField) const +OUString SwAuthorityField::GetFieldText(ToxAuthorityField eField) const { SwAuthorityFieldType* pAuthType = (SwAuthorityFieldType*)GetTyp(); const SwAuthEntry* pEntry = pAuthType->GetEntryByHandle( m_nHandle ); @@ -583,7 +586,7 @@ void SwAuthorityField::SetPar1(const OUString& rStr) m_nHandle = pInitType->AddField(rStr); } -String SwAuthorityField::GetDescription() const +OUString SwAuthorityField::GetDescription() const { return SW_RES(STR_AUTHORITY_ENTRY); } @@ -635,11 +638,11 @@ bool SwAuthorityField::QueryValue( Any& rAny, sal_uInt16 /*nWhichId*/ ) const for(sal_Int16 i = 0; i < AUTH_FIELD_END; i++) { pValues[i].Name = OUString::createFromAscii(aFieldNames[i]); - const String& rField = pAuthEntry->GetAuthorField((ToxAuthorityField) i); + const OUString sField = pAuthEntry->GetAuthorField((ToxAuthorityField) i); if(i == AUTH_FIELD_AUTHORITY_TYPE) - pValues[i].Value <<= sal_Int16(rField.ToInt32()); + pValues[i].Value <<= sal_Int16(sField.toInt32()); else - pValues[i].Value <<= OUString(rField); + pValues[i].Value <<= sField; } rAny <<= aRet; /* FIXME: it is weird that we always return false here */ diff --git a/sw/source/core/fields/chpfld.cxx b/sw/source/core/fields/chpfld.cxx index e469c574ff72..ddda6c4c1dc7 100644 --- a/sw/source/core/fields/chpfld.cxx +++ b/sw/source/core/fields/chpfld.cxx @@ -29,6 +29,28 @@ using namespace ::com::sun::star; +namespace +{ + +OUString removeControlChars(OUString sIn) +{ + OUStringBuffer aBuf(sIn); + sal_Int32 nLen = aBuf.getLength(); + for (sal_Int32 i = 0; i < nLen; ++i) + { + if (aBuf[i] < ' ') + { + sal_Int32 j = i+1; + while (j sTitle.GetChar( i ) ) - sTitle.Erase( i--, 1 ); + sTitle = removeControlChars(rTxtNd.GetExpandTxt()); } else { @@ -185,14 +201,11 @@ void SwChapterField::ChangeExpansion(const SwTxtNode &rTxtNd, sal_Bool bSrchNum) } else { - sNumber = String("??", RTL_TEXTENCODING_ASCII_US); + sNumber = "??"; } - sTitle = pTxtNd->GetExpandTxt(); + sTitle = removeControlChars(pTxtNd->GetExpandTxt()); - for( xub_StrLen i = 0; i < sTitle.Len(); ++i ) - if( ' ' > sTitle.GetChar( i ) ) - sTitle.Erase( i--, 1 ); } } } diff --git a/sw/source/core/fields/dbfld.cxx b/sw/source/core/fields/dbfld.cxx index f3e81116d302..8b7d7e085326 100644 --- a/sw/source/core/fields/dbfld.cxx +++ b/sw/source/core/fields/dbfld.cxx @@ -43,30 +43,28 @@ using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star; /// replace database separator by dots for display -static String lcl_DBTrennConv(const String& aContent) +static OUString lcl_DBTrennConv(const OUString& aContent) { - String sTmp(aContent); - sal_Unicode* pStr = sTmp.GetBufferAccess(); - for( sal_uInt16 i = sTmp.Len(); i; --i, ++pStr ) - if( DB_DELIM == *pStr ) - *pStr = '.'; - return sTmp; + return aContent.replaceAll(OUString(DB_DELIM), OUString('.')); } // database field type -SwDBFieldType::SwDBFieldType(SwDoc* pDocPtr, const String& rNam, const SwDBData& rDBData ) : +SwDBFieldType::SwDBFieldType(SwDoc* pDocPtr, const OUString& rNam, const SwDBData& rDBData ) : SwValueFieldType( pDocPtr, RES_DBFLD ), aDBData(rDBData), + sName(rNam), sColumn(rNam), nRefCnt(0) { if(!aDBData.sDataSource.isEmpty() || !aDBData.sCommand.isEmpty()) { - sName = OUStringBuffer(aDBData.sDataSource).append(DB_DELIM). - append(aDBData.sCommand).append(DB_DELIM).makeStringAndClear(); + sName = aDBData.sDataSource + + OUString(DB_DELIM) + + aDBData.sCommand + + OUString(DB_DELIM) + + sName; } - sName += GetColumnName(); } SwDBFieldType::~SwDBFieldType() @@ -79,7 +77,7 @@ SwFieldType* SwDBFieldType::Copy() const return pTmp; } -const OUString& SwDBFieldType::GetName() const +OUString SwDBFieldType::GetName() const { return sName; } @@ -111,7 +109,7 @@ bool SwDBFieldType::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const rAny <<= aDBData.sCommand; break; case FIELD_PROP_PAR3: - rAny <<= OUString(sColumn); + rAny <<= sColumn; break; case FIELD_PROP_SHORT1: rAny <<= aDBData.nCommandType; @@ -134,8 +132,8 @@ bool SwDBFieldType::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) break; case FIELD_PROP_PAR3: { - String sTmp; - ::GetString( rAny, sTmp ); + OUString sTmp; + rAny >>= sTmp; if( sTmp != sColumn ) { sColumn = sTmp; @@ -150,7 +148,7 @@ bool SwDBFieldType::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) SwDBField* pDBField = (SwDBField*)pFld->GetFld(); pDBField->ClearInitialized(); pDBField->InitContent(); - } + } pFld = aIter.Next(); } } @@ -189,38 +187,30 @@ void SwDBField::InitContent() { if (!IsInitialized()) { - aContent = OUStringBuffer().append('<') - .append(((const SwDBFieldType*)GetTyp())->GetColumnName()) - .append('>').makeStringAndClear(); + aContent = "<" + ((const SwDBFieldType*)GetTyp())->GetColumnName() + ">"; } } -void SwDBField::InitContent(const String& rExpansion) +void SwDBField::InitContent(const OUString& rExpansion) { - if (rExpansion.Len() > 2) + if (rExpansion.startsWith("<") && rExpansion.endsWith(">")) { - if (rExpansion.GetChar(0) == '<' && - rExpansion.GetChar(rExpansion.Len() - 1) == '>') + const OUString sColumn( rExpansion.copy( 1, rExpansion.getLength() - 2 ) ); + if( ::GetAppCmpStrIgnore().isEqual( sColumn, + ((SwDBFieldType *)GetTyp())->GetColumnName() )) { - String sColumn( rExpansion.Copy( 1, rExpansion.Len() - 2 ) ); - if( ::GetAppCmpStrIgnore().isEqual( sColumn, - ((SwDBFieldType *)GetTyp())->GetColumnName() )) - { - InitContent(); - return; - } + InitContent(); + return; } } SetExpansion( rExpansion ); } -String SwDBField::Expand() const +OUString SwDBField::Expand() const { - String sRet; - if(0 ==(GetSubType() & nsSwExtendedSubType::SUB_INVISIBLE)) - sRet = lcl_DBTrennConv(aContent); - return sRet; + return lcl_DBTrennConv(aContent); + return OUString(); } SwField* SwDBField::Copy() const @@ -237,18 +227,18 @@ SwField* SwDBField::Copy() const return pTmp; } -String SwDBField::GetFieldName() const +OUString SwDBField::GetFieldName() const { - const String& rDBName = static_cast(GetTyp())->GetName(); + const OUString rDBName = static_cast(GetTyp())->GetName(); - String sContent( rDBName.GetToken(0, DB_DELIM) ); + OUString sContent( rDBName.getToken(0, DB_DELIM) ); - if (sContent.Len() > 1) + if (sContent.getLength() > 1) { - sContent += DB_DELIM; - sContent += rDBName.GetToken(1, DB_DELIM); - sContent += DB_DELIM; - sContent += rDBName.GetToken(2, DB_DELIM); + sContent += OUString(DB_DELIM) + + rDBName.getToken(1, DB_DELIM) + + OUString(DB_DELIM) + + rDBName.getToken(2, DB_DELIM); } return lcl_DBTrennConv(sContent); } @@ -334,7 +324,7 @@ void SwDBField::Evaluate() } /// get name -const OUString& SwDBField::GetPar1() const +OUString SwDBField::GetPar1() const { return ((const SwDBFieldType*)GetTyp())->GetName(); } @@ -369,10 +359,10 @@ bool SwDBField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const rAny <<= (sal_Int32)GetFormat(); break; case FIELD_PROP_PAR1: - rAny <<= OUString(aContent); + rAny <<= aContent; break; case FIELD_PROP_PAR2: - rAny <<= OUString(sFieldCode); + rAny <<= sFieldCode; break; default: OSL_FAIL("illegal property"); @@ -463,15 +453,15 @@ void SwDBNameInfField::SetDBData(const SwDBData & rDBData) aDBData = rDBData; } -String SwDBNameInfField::GetFieldName() const +OUString SwDBNameInfField::GetFieldName() const { - String sStr( SwField::GetFieldName() ); + OUString sStr( SwField::GetFieldName() ); if (!aDBData.sDataSource.isEmpty()) { - sStr += ':'; - sStr += String(aDBData.sDataSource); - sStr += DB_DELIM; - sStr += String(aDBData.sCommand); + sStr += OUString(':') + + aDBData.sDataSource + + OUString(DB_DELIM) + + aDBData.sCommand; } return lcl_DBTrennConv(sStr); } @@ -559,21 +549,21 @@ SwFieldType* SwDBNextSetFieldType::Copy() const // SwDBSetField SwDBNextSetField::SwDBNextSetField(SwDBNextSetFieldType* pTyp, - const String& rCond, - const String& , + const OUString& rCond, + const OUString& , const SwDBData& rDBData) : SwDBNameInfField(pTyp, rDBData), aCond(rCond), bCondValid(true) {} -String SwDBNextSetField::Expand() const +OUString SwDBNextSetField::Expand() const { - return aEmptyStr; + return OUString(); } SwField* SwDBNextSetField::Copy() const { SwDBNextSetField *pTmp = new SwDBNextSetField((SwDBNextSetFieldType*)GetTyp(), - aCond, aEmptyStr, GetDBData()); + aCond, OUString(), GetDBData()); pTmp->SetSubType(GetSubType()); pTmp->bCondValid = bCondValid; return pTmp; @@ -590,7 +580,7 @@ void SwDBNextSetField::Evaluate(SwDoc* pDoc) } /// get condition -const OUString& SwDBNextSetField::GetPar1() const +OUString SwDBNextSetField::GetPar1() const { return aCond; } @@ -607,7 +597,7 @@ bool SwDBNextSetField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const switch( nWhichId ) { case FIELD_PROP_PAR3: - rAny <<= OUString(aCond); + rAny <<= aCond; break; default: bRet = SwDBNameInfField::QueryValue( rAny, nWhichId ); @@ -645,8 +635,8 @@ SwFieldType* SwDBNumSetFieldType::Copy() const // SwDBNumSetField SwDBNumSetField::SwDBNumSetField(SwDBNumSetFieldType* pTyp, - const String& rCond, - const String& rDBNum, + const OUString& rCond, + const OUString& rDBNum, const SwDBData& rDBData) : SwDBNameInfField(pTyp, rDBData), aCond(rCond), @@ -654,9 +644,9 @@ SwDBNumSetField::SwDBNumSetField(SwDBNumSetFieldType* pTyp, bCondValid(true) {} -String SwDBNumSetField::Expand() const +OUString SwDBNumSetField::Expand() const { - return aEmptyStr; + return OUString(); } SwField* SwDBNumSetField::Copy() const @@ -676,12 +666,12 @@ void SwDBNumSetField::Evaluate(SwDoc* pDoc) if( bCondValid && pMgr && pMgr->IsInMerge() && pMgr->IsDataSourceOpen(aTmpData.sDataSource, aTmpData.sCommand, sal_True)) { // Bedingug OK -> aktuellen Set einstellen - pMgr->ToRecordId(std::max((sal_uInt16)aPar2.ToInt32(), sal_uInt16(1))-1); + pMgr->ToRecordId(std::max((sal_uInt16)aPar2.toInt32(), sal_uInt16(1))-1); } } /// get LogDBName -const OUString& SwDBNumSetField::GetPar1() const +OUString SwDBNumSetField::GetPar1() const { return aCond; } @@ -710,10 +700,10 @@ bool SwDBNumSetField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const switch( nWhichId ) { case FIELD_PROP_PAR3: - rAny <<= OUString(aCond); + rAny <<= aCond; break; case FIELD_PROP_FORMAT: - rAny <<= (sal_Int32)aPar2.ToInt32(); + rAny <<= aPar2.toInt32(); break; default: bRet = SwDBNameInfField::QueryValue(rAny, nWhichId ); @@ -750,13 +740,10 @@ SwDBNameFieldType::SwDBNameFieldType(SwDoc* pDocument) pDoc = pDocument; } -String SwDBNameFieldType::Expand(sal_uLong ) const +OUString SwDBNameFieldType::Expand(sal_uLong ) const { const SwDBData aData = pDoc->GetDBData(); - String sRet(aData.sDataSource); - sRet += '.'; - sRet += (String)aData.sCommand; - return sRet; + return aData.sDataSource + "." + aData.sCommand; } SwFieldType* SwDBNameFieldType::Copy() const @@ -771,12 +758,11 @@ SwDBNameField::SwDBNameField(SwDBNameFieldType* pTyp, const SwDBData& rDBData, s : SwDBNameInfField(pTyp, rDBData, nFmt) {} -String SwDBNameField::Expand() const +OUString SwDBNameField::Expand() const { - String sRet; if(0 ==(GetSubType() & nsSwExtendedSubType::SUB_INVISIBLE)) - sRet = ((SwDBNameFieldType*)GetTyp())->Expand(GetFormat()); - return sRet; + return ((SwDBNameFieldType*)GetTyp())->Expand(GetFormat()); + return OUString(); } SwField* SwDBNameField::Copy() const @@ -819,12 +805,11 @@ SwDBSetNumberField::SwDBSetNumberField(SwDBSetNumberFieldType* pTyp, : SwDBNameInfField(pTyp, rDBData, nFmt), nNumber(0) {} -String SwDBSetNumberField::Expand() const +OUString SwDBSetNumberField::Expand() const { if(0 !=(GetSubType() & nsSwExtendedSubType::SUB_INVISIBLE) || nNumber == 0) - return aEmptyStr; - else - return FormatNumber((sal_uInt16)nNumber, GetFormat()); + return OUString(); + return FormatNumber((sal_uInt16)nNumber, GetFormat()); } void SwDBSetNumberField::Evaluate(SwDoc* pDoc) diff --git a/sw/source/core/fields/ddefld.cxx b/sw/source/core/fields/ddefld.cxx index 1ec60355b4d8..6fd3c0824ccf 100644 --- a/sw/source/core/fields/ddefld.cxx +++ b/sw/source/core/fields/ddefld.cxx @@ -17,7 +17,6 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include #include #include #include @@ -228,8 +227,8 @@ sal_Bool SwIntrnlRefLink::IsInRange( sal_uLong nSttNd, sal_uLong nEndNd, return sal_False; } -SwDDEFieldType::SwDDEFieldType(const String& rName, - const String& rCmd, sal_uInt16 nUpdateType ) +SwDDEFieldType::SwDDEFieldType(const OUString& rName, + const OUString& rCmd, sal_uInt16 nUpdateType ) : SwFieldType( RES_DDEFLD ), aName( rName ), pDoc( 0 ), nRefCnt( 0 ) { @@ -255,21 +254,22 @@ SwFieldType* SwDDEFieldType::Copy() const return pType; } -const OUString& SwDDEFieldType::GetName() const +OUString SwDDEFieldType::GetName() const { return aName; } -void SwDDEFieldType::SetCmd( const String& rStr ) +void SwDDEFieldType::SetCmd( OUString aStr ) { - String sCmd( rStr ); - xub_StrLen nPos; - while( STRING_NOTFOUND != (nPos = sCmd.SearchAscii( " " )) ) - sCmd.Erase( nPos, 1 ); - refLink->SetLinkSourceName( sCmd ); + sal_Int32 nIndex = 0; + do + { + aStr = aStr.replaceFirst(" ", " ", &nIndex); + } while (nIndex>=0); + refLink->SetLinkSourceName( aStr ); } -String SwDDEFieldType::GetCmd() const +OUString SwDDEFieldType::GetCmd() const { return refLink->GetLinkSourceName(); } @@ -312,12 +312,12 @@ void SwDDEFieldType::_RefCntChgd() bool SwDDEFieldType::QueryValue( uno::Any& rVal, sal_uInt16 nWhichId ) const { - sal_uInt8 nPart = 0; + sal_Int32 nPart = -1; switch( nWhichId ) { - case FIELD_PROP_PAR2: nPart = 3; break; - case FIELD_PROP_PAR4: nPart = 2; break; - case FIELD_PROP_SUBTYPE: nPart = 1; break; + case FIELD_PROP_PAR2: nPart = 2; break; + case FIELD_PROP_PAR4: nPart = 1; break; + case FIELD_PROP_SUBTYPE: nPart = 0; break; case FIELD_PROP_BOOL1: { sal_Bool bSet = GetType() == sfx2::LINKUPDATE_ALWAYS ? sal_True : sal_False; @@ -325,46 +325,50 @@ bool SwDDEFieldType::QueryValue( uno::Any& rVal, sal_uInt16 nWhichId ) const } break; case FIELD_PROP_PAR5: - rVal <<= OUString(aExpansion); - break; + rVal <<= aExpansion; + break; default: OSL_FAIL("illegal property"); } - if( nPart ) - rVal <<= OUString(GetCmd().GetToken(nPart-1, sfx2::cTokenSeparator)); + if ( nPart>=0 ) + rVal <<= GetCmd().getToken(nPart, sfx2::cTokenSeparator); return true; } bool SwDDEFieldType::PutValue( const uno::Any& rVal, sal_uInt16 nWhichId ) { - sal_uInt8 nPart = 0; + sal_Int32 nPart = -1; switch( nWhichId ) { - case FIELD_PROP_PAR2: nPart = 3; break; - case FIELD_PROP_PAR4: nPart = 2; break; - case FIELD_PROP_SUBTYPE: nPart = 1; break; + case FIELD_PROP_PAR2: nPart = 2; break; + case FIELD_PROP_PAR4: nPart = 1; break; + case FIELD_PROP_SUBTYPE: nPart = 0; break; case FIELD_PROP_BOOL1: SetType( static_cast(*(sal_Bool*)rVal.getValue() ? sfx2::LINKUPDATE_ALWAYS : sfx2::LINKUPDATE_ONCALL ) ); break; case FIELD_PROP_PAR5: - { - OUString sTemp; - rVal >>= sTemp; - aExpansion = sTemp; - } - break; + rVal >>= aExpansion; + break; default: OSL_FAIL("illegal property"); } - if( nPart ) + if( nPart>=0 ) { - String sTmp, sCmd( GetCmd() ); - while(3 > comphelper::string::getTokenCount(sCmd, sfx2::cTokenSeparator)) - sCmd += sfx2::cTokenSeparator; - sCmd.SetToken( nPart-1, sfx2::cTokenSeparator, ::GetString( rVal, sTmp ) ); - SetCmd( sCmd ); + const OUString sOldCmd( GetCmd() ); + OUString sNewCmd; + sal_Int32 nIndex = 0; + for (sal_Int32 i=0; i<3; ++i) + { + OUString sToken = sOldCmd.getToken(0, sfx2::cTokenSeparator, nIndex); + if (i==nPart) + { + rVal >>= sToken; + } + sNewCmd += sToken + OUString(sfx2::cTokenSeparator); + } + SetCmd( sNewCmd ); } return true; } @@ -380,17 +384,16 @@ SwDDEField::~SwDDEField() ((SwDDEFieldType*)GetTyp())->Disconnect(); } -String SwDDEField::Expand() const +OUString SwDDEField::Expand() const { - xub_StrLen nPos; - String aStr(comphelper::string::remove(((SwDDEFieldType*)GetTyp())->GetExpansion(), '\r')); - - while( (nPos = aStr.Search( '\t' )) != STRING_NOTFOUND ) - aStr.SetChar( nPos, ' ' ); - while( (nPos = aStr.Search( '\n' )) != STRING_NOTFOUND ) - aStr.SetChar( nPos, '|' ); - if( aStr.Len() && ( aStr.GetChar( aStr.Len()-1 ) == '|') ) - aStr.Erase( aStr.Len()-1, 1 ); + OUString aStr = ((SwDDEFieldType*)GetTyp())->GetExpansion(); + aStr = aStr.replaceAll("\r", OUString()); + aStr = aStr.replaceAll("\t", " "); + aStr = aStr.replaceAll("\n", "|"); + if (aStr.endsWith("|")) + { + return aStr.copy(0, aStr.getLength()-1); + } return aStr; } @@ -400,7 +403,7 @@ SwField* SwDDEField::Copy() const } /// get field type name -const OUString& SwDDEField::GetPar1() const +OUString SwDDEField::GetPar1() const { return ((const SwDDEFieldType*)GetTyp())->GetName(); } diff --git a/sw/source/core/fields/docufld.cxx b/sw/source/core/fields/docufld.cxx index 891e72cb384e..c8eb6f468da5 100644 --- a/sw/source/core/fields/docufld.cxx +++ b/sw/source/core/fields/docufld.cxx @@ -108,20 +108,20 @@ SwPageNumberFieldType::SwPageNumberFieldType() { } -String& SwPageNumberFieldType::Expand( sal_uInt32 nFmt, short nOff, +OUString SwPageNumberFieldType::Expand( sal_uInt32 nFmt, short nOff, sal_uInt16 const nPageNumber, sal_uInt16 const nMaxPage, - const String& rUserStr, String& rRet ) const + const OUString& rUserStr ) const { sal_uInt32 nTmpFmt = (SVX_NUM_PAGEDESC == nFmt) ? (sal_uInt32)nNumberingType : nFmt; int const nTmp = nPageNumber + nOff; if (0 >= nTmp || SVX_NUM_NUMBER_NONE == nTmpFmt || (!bVirtuell && nTmp > nMaxPage)) - rRet = aEmptyStr; - else if( SVX_NUM_CHAR_SPECIAL == nTmpFmt ) - rRet = rUserStr; - else - rRet = FormatNumber( (sal_uInt16)nTmp, nTmpFmt ); - return rRet; + return OUString(); + + if( SVX_NUM_CHAR_SPECIAL == nTmpFmt ) + return rUserStr; + + return FormatNumber( (sal_uInt16)nTmp, nTmpFmt ); } SwFieldType* SwPageNumberFieldType::Copy() const @@ -186,32 +186,29 @@ void SwPageNumberField::ChangeExpansion(sal_uInt16 const nPageNumber, m_nMaxPage = nMaxPage; } -String SwPageNumberField::Expand() const +OUString SwPageNumberField::Expand() const { - String sRet; + OUString sRet; SwPageNumberFieldType* pFldType = (SwPageNumberFieldType*)GetTyp(); if( PG_NEXT == nSubType && 1 != nOffset ) { - if (pFldType->Expand(GetFormat(), 1, m_nPageNumber, m_nMaxPage, - sUserStr, sRet).Len()) + sRet = pFldType->Expand(GetFormat(), 1, m_nPageNumber, m_nMaxPage, sUserStr); + if (!sRet.isEmpty()) { - pFldType->Expand(GetFormat(), nOffset, m_nPageNumber, m_nMaxPage, - sUserStr, sRet); + sRet = pFldType->Expand(GetFormat(), nOffset, m_nPageNumber, m_nMaxPage, sUserStr); } } else if( PG_PREV == nSubType && -1 != nOffset ) { - if (pFldType->Expand(GetFormat(), -1, m_nPageNumber, m_nMaxPage, - sUserStr, sRet).Len()) + sRet = pFldType->Expand(GetFormat(), -1, m_nPageNumber, m_nMaxPage, sUserStr); + if (!sRet.isEmpty()) { - pFldType->Expand(GetFormat(), nOffset, m_nPageNumber, m_nMaxPage, - sUserStr, sRet); + sRet = pFldType->Expand(GetFormat(), nOffset, m_nPageNumber, m_nMaxPage, sUserStr); } } else - pFldType->Expand(GetFormat(), nOffset, m_nPageNumber, m_nMaxPage, - sUserStr, sRet); + sRet = pFldType->Expand(GetFormat(), nOffset, m_nPageNumber, m_nMaxPage, sUserStr); return sRet; } @@ -262,7 +259,7 @@ bool SwPageNumberField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const } break; case FIELD_PROP_PAR1: - rAny <<= OUString(sUserStr); + rAny <<= sUserStr; break; default: @@ -307,7 +304,7 @@ bool SwPageNumberField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) } break; case FIELD_PROP_PAR1: - ::GetString( rAny, sUserStr ); + rAny >>= sUserStr; break; default: @@ -322,15 +319,13 @@ SwAuthorFieldType::SwAuthorFieldType() { } -String SwAuthorFieldType::Expand(sal_uLong nFmt) const +OUString SwAuthorFieldType::Expand(sal_uLong nFmt) const { - String sRet; SvtUserOptions& rOpt = SW_MOD()->GetUserOptions(); if((nFmt & 0xff) == AF_NAME) - sRet = rOpt.GetFullName(); - else - sRet = rOpt.GetID(); - return sRet; + return rOpt.GetFullName(); + + return rOpt.GetID(); } SwFieldType* SwAuthorFieldType::Copy() const @@ -346,7 +341,7 @@ SwAuthorField::SwAuthorField(SwAuthorFieldType* pTyp, sal_uInt32 nFmt) aContent = ((SwAuthorFieldType*)GetTyp())->Expand(GetFormat()); } -String SwAuthorField::Expand() const +OUString SwAuthorField::Expand() const { if (!IsFixed()) ((SwAuthorField*)this)->aContent = @@ -379,7 +374,7 @@ bool SwAuthorField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const break; case FIELD_PROP_PAR1: - rAny <<= OUString(GetContent()); + rAny <<= GetContent(); break; default: @@ -404,7 +399,7 @@ bool SwAuthorField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) break; case FIELD_PROP_PAR1: - ::GetString( rAny, aContent ); + rAny >>= aContent; break; default: @@ -421,9 +416,9 @@ SwFileNameFieldType::SwFileNameFieldType(SwDoc *pDocument) pDoc = pDocument; } -String SwFileNameFieldType::Expand(sal_uLong nFmt) const +OUString SwFileNameFieldType::Expand(sal_uLong nFmt) const { - String aRet; + OUString aRet; const SwDocShell* pDShell = pDoc->GetDocShell(); if( pDShell && pDShell->HasName() ) { @@ -444,8 +439,11 @@ String SwFileNameFieldType::Expand(sal_uLong nFmt) const aRet = URIHelper::removePassword( rURLObj.GetMainURL( INetURLObject::NO_DECODE ), INetURLObject::WAS_ENCODED, URL_DECODE ); - aRet.Erase( aRet.Search( String(rURLObj.GetLastName( - URL_DECODE )) ) ); + const sal_Int32 nPos = aRet.indexOf(rURLObj.GetLastName( URL_DECODE )); + if (nPos>=0) + { + aRet = aRet.copy(0, nPos); + } } } break; @@ -484,7 +482,7 @@ SwFileNameField::SwFileNameField(SwFileNameFieldType* pTyp, sal_uInt32 nFmt) aContent = ((SwFileNameFieldType*)GetTyp())->Expand(GetFormat()); } -String SwFileNameField::Expand() const +OUString SwFileNameField::Expand() const { if (!IsFixed()) ((SwFileNameField*)this)->aContent = ((SwFileNameFieldType*)GetTyp())->Expand(GetFormat()); @@ -533,7 +531,7 @@ bool SwFileNameField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const break; case FIELD_PROP_PAR3: - rAny <<= OUString(GetContent()); + rAny <<= GetContent(); break; default: OSL_FAIL("illegal property"); @@ -580,7 +578,7 @@ bool SwFileNameField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) break; case FIELD_PROP_PAR3: - ::GetString( rAny, aContent ); + rAny >>= aContent; break; default: @@ -597,11 +595,11 @@ SwTemplNameFieldType::SwTemplNameFieldType(SwDoc *pDocument) pDoc = pDocument; } -String SwTemplNameFieldType::Expand(sal_uLong nFmt) const +OUString SwTemplNameFieldType::Expand(sal_uLong nFmt) const { OSL_ENSURE( nFmt < FF_END, "Expand: kein guelt. Fmt!" ); - String aRet; + OUString aRet; SwDocShell *pDocShell(pDoc->GetDocShell()); OSL_ENSURE(pDocShell, "no SwDocShell"); if (pDocShell) { @@ -621,7 +619,9 @@ String SwTemplNameFieldType::Expand(sal_uLong nFmt) const SfxDocumentTemplates aFac; aFac.Construct(); String sTmp; - aFac.GetLogicNames( xDocProps->getTemplateURL(), aRet, sTmp ); + String sRegion; + aFac.GetLogicNames( xDocProps->getTemplateURL(), sRegion, sTmp ); + aRet = sRegion; } else { @@ -657,7 +657,7 @@ SwTemplNameField::SwTemplNameField(SwTemplNameFieldType* pTyp, sal_uInt32 nFmt) : SwField(pTyp, nFmt) {} -String SwTemplNameField::Expand() const +OUString SwTemplNameField::Expand() const { return((SwTemplNameFieldType*)GetTyp())->Expand(GetFormat()); } @@ -741,7 +741,7 @@ SwDocStatFieldType::SwDocStatFieldType(SwDoc* pDocument) pDoc = pDocument; } -String SwDocStatFieldType::Expand(sal_uInt16 nSubType, sal_uInt32 nFmt) const +OUString SwDocStatFieldType::Expand(sal_uInt16 nSubType, sal_uInt32 nFmt) const { sal_uInt32 nVal = 0; const SwDocStat& rDStat = pDoc->GetDocStat(); @@ -764,12 +764,10 @@ String SwDocStatFieldType::Expand(sal_uInt16 nSubType, sal_uInt32 nFmt) const OSL_FAIL( "SwDocStatFieldType::Expand: unbekannter SubType" ); } - String sRet; if( nVal <= SHRT_MAX ) - sRet = FormatNumber( (sal_uInt16)nVal, nFmt ); - else - sRet = OUString::number( nVal ); - return sRet; + return FormatNumber( (sal_uInt16)nVal, nFmt ); + + return OUString::number( nVal ); } SwFieldType* SwDocStatFieldType::Copy() const @@ -788,7 +786,7 @@ SwDocStatField::SwDocStatField(SwDocStatFieldType* pTyp, sal_uInt16 nSub, sal_uI nSubType(nSub) {} -String SwDocStatField::Expand() const +OUString SwDocStatField::Expand() const { return((SwDocStatFieldType*)GetTyp())->Expand(nSubType, GetFormat()); } @@ -880,14 +878,13 @@ static void lcl_GetLocalDataWrapper( sal_uLong nLang, LanguageTag( static_cast(nLang) )); } -String SwDocInfoFieldType::Expand( sal_uInt16 nSub, sal_uInt32 nFormat, - sal_uInt16 nLang, const String& rName ) const +OUString SwDocInfoFieldType::Expand( sal_uInt16 nSub, sal_uInt32 nFormat, + sal_uInt16 nLang, const OUString& rName ) const { - String aStr; const LocaleDataWrapper *pAppLocalData = 0, *pLocalData = 0; SwDocShell *pDocShell(GetDoc()->GetDocShell()); OSL_ENSURE(pDocShell, "no SwDocShell"); - if (!pDocShell) { return aStr; } + if (!pDocShell) { return OUString(); } uno::Reference xDPS( pDocShell->GetModel(), uno::UNO_QUERY_THROW); @@ -898,6 +895,7 @@ String SwDocInfoFieldType::Expand( sal_uInt16 nSub, sal_uInt32 nFormat, sal_uInt16 nExtSub = nSub & 0xff00; nSub &= 0xff; // ExtendedSubTypes nicht beachten + OUString aStr; switch(nSub) { case DI_TITEL: aStr = xDocProps->getTitle(); break; @@ -946,7 +944,7 @@ String SwDocInfoFieldType::Expand( sal_uInt16 nSub, sal_uInt32 nFormat, default: { - String aName( xDocProps->getAuthor() ); + OUString aName( xDocProps->getAuthor() ); util::DateTime uDT( xDocProps->getCreationDate() ); Date aD(uDT.Day, uDT.Month, uDT.Year); Time aT(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.NanoSeconds); @@ -1028,14 +1026,14 @@ String SwDocInfoFieldType::Expand( sal_uInt16 nSub, sal_uInt32 nFormat, // document info field -SwDocInfoField::SwDocInfoField(SwDocInfoFieldType* pTyp, sal_uInt16 nSub, const String& rName, sal_uInt32 nFmt) : +SwDocInfoField::SwDocInfoField(SwDocInfoFieldType* pTyp, sal_uInt16 nSub, const OUString& rName, sal_uInt32 nFmt) : SwValueField(pTyp, nFmt), nSubType(nSub) { aName = rName; aContent = ((SwDocInfoFieldType*)GetTyp())->Expand(nSubType, nFmt, GetLanguage(), aName); } -SwDocInfoField::SwDocInfoField(SwDocInfoFieldType* pTyp, sal_uInt16 nSub, const String& rName, const String& rValue, sal_uInt32 nFmt) : +SwDocInfoField::SwDocInfoField(SwDocInfoFieldType* pTyp, sal_uInt16 nSub, const OUString& rName, const OUString& rValue, sal_uInt32 nFmt) : SwValueField(pTyp, nFmt), nSubType(nSub) { aName = rName; @@ -1057,7 +1055,7 @@ static double lcl_DateToDouble( const D& rDate, const Date& rNullDate ) return double( nDate - nNullDate ); } -String SwDocInfoField::Expand() const +OUString SwDocInfoField::Expand() const { if ( ( nSubType & 0xFF ) == DI_CUSTOM ) { @@ -1108,15 +1106,14 @@ String SwDocInfoField::Expand() const } else if( aAny >>= aDuration ) { - String sText = aDuration.Negative ? OUString('-') : OUString('+'); - sText += ViewShell::GetShellRes()->sDurationFormat; - sText.SearchAndReplace(OUString("%1"), OUString::number( aDuration.Years ) ); - sText.SearchAndReplace(OUString("%2"), OUString::number( aDuration.Months ) ); - sText.SearchAndReplace(OUString("%3"), OUString::number( aDuration.Days ) ); - sText.SearchAndReplace(OUString("%4"), OUString::number( aDuration.Hours ) ); - sText.SearchAndReplace(OUString("%5"), OUString::number( aDuration.Minutes) ); - sText.SearchAndReplace(OUString("%6"), OUString::number( aDuration.Seconds) ); - sVal = sText; + sVal = OUString(aDuration.Negative ? '-' : '+') + + ViewShell::GetShellRes()->sDurationFormat; + sVal = sVal.replaceFirst("%1", OUString::number( aDuration.Years ) ); + sVal = sVal.replaceFirst("%2", OUString::number( aDuration.Months ) ); + sVal = sVal.replaceFirst("%3", OUString::number( aDuration.Days ) ); + sVal = sVal.replaceFirst("%4", OUString::number( aDuration.Hours ) ); + sVal = sVal.replaceFirst("%5", OUString::number( aDuration.Minutes) ); + sVal = sVal.replaceFirst("%6", OUString::number( aDuration.Seconds) ); } else { @@ -1135,10 +1132,9 @@ String SwDocInfoField::Expand() const return aContent; } -String SwDocInfoField::GetFieldName() const +OUString SwDocInfoField::GetFieldName() const { - String aStr(SwFieldType::GetTypeStr(GetTypeId())); - aStr += ':'; + OUString aStr(SwFieldType::GetTypeStr(GetTypeId()) + ":"); sal_uInt16 const nSub = nSubType & 0xff; @@ -1155,8 +1151,7 @@ String SwDocInfoField::GetFieldName() const } if (IsFixed()) { - aStr += ' '; - aStr += ViewShell::GetShellRes()->aFixedStr; + aStr += " " + OUString(ViewShell::GetShellRes()->aFixedStr); } return aStr; } @@ -1193,15 +1188,15 @@ bool SwDocInfoField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const switch( nWhichId ) { case FIELD_PROP_PAR1: - rAny <<= OUString(aContent); + rAny <<= aContent; break; case FIELD_PROP_PAR4: - rAny <<= OUString(aName); + rAny <<= aName; break; case FIELD_PROP_USHORT1: - rAny <<= (sal_Int16)aContent.ToInt32(); + rAny <<= (sal_Int16)aContent.toInt32(); break; case FIELD_PROP_BOOL1: @@ -1221,7 +1216,7 @@ bool SwDocInfoField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const } break; case FIELD_PROP_PAR3: - rAny <<= OUString(Expand()); + rAny <<= Expand(); break; case FIELD_PROP_BOOL2: { @@ -1243,7 +1238,7 @@ bool SwDocInfoField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) { case FIELD_PROP_PAR1: if( nSubType & DI_SUB_FIXED ) - ::GetString( rAny, aContent ); + rAny >>= aContent; break; case FIELD_PROP_USHORT1: @@ -1269,7 +1264,7 @@ bool SwDocInfoField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) break; case FIELD_PROP_PAR3: - ::GetString( rAny, aContent ); + rAny >>= aContent; break; case FIELD_PROP_BOOL2: nSubType &= 0xf0ff; @@ -1307,8 +1302,8 @@ void SwHiddenTxtFieldType::SetHiddenFlag( sal_Bool bSetHidden ) SwHiddenTxtField::SwHiddenTxtField( SwHiddenTxtFieldType* pFldType, sal_Bool bConditional, - const String& rCond, - const String& rStr, + const OUString& rCond, + const OUString& rStr, sal_Bool bHidden, sal_uInt16 nSub) : SwField( pFldType ), aCond(rCond), nSubType(nSub), @@ -1317,14 +1312,14 @@ SwHiddenTxtField::SwHiddenTxtField( SwHiddenTxtFieldType* pFldType, if(nSubType == TYP_CONDTXTFLD) { sal_Int32 nPos = 0; - aTRUETxt = rStr.GetToken(0, '|', nPos); + aTRUETxt = rStr.getToken(0, '|', nPos); if(nPos != -1) { - aFALSETxt = rStr.GetToken(0, '|', nPos); + aFALSETxt = rStr.getToken(0, '|', nPos); if(nPos != -1) { - aContent = rStr.GetToken(0, '|', nPos); + aContent = rStr.getToken(0, '|', nPos); bValid = sal_True; } } @@ -1334,17 +1329,17 @@ SwHiddenTxtField::SwHiddenTxtField( SwHiddenTxtFieldType* pFldType, } SwHiddenTxtField::SwHiddenTxtField( SwHiddenTxtFieldType* pFldType, - const String& rCond, - const String& rTrue, - const String& rFalse, + const OUString& rCond, + const OUString& rTrue, + const OUString& rFalse, sal_uInt16 nSub) : SwField( pFldType ), aTRUETxt(rTrue), aFALSETxt(rFalse), aCond(rCond), nSubType(nSub), bIsHidden(sal_True), bValid(sal_False) { - bCanToggle = aCond.getLength() > 0; + bCanToggle = !aCond.isEmpty(); } -String SwHiddenTxtField::Expand() const +OUString SwHiddenTxtField::Expand() const { // Type: !Hidden -> show always // Hide -> evaluate condition @@ -1374,38 +1369,33 @@ void SwHiddenTxtField::Evaluate(SwDoc* pDoc) SwNewDBMgr* pMgr = pDoc->GetNewDBMgr(); bValid = sal_False; - String sTmpName; + OUString sTmpName = (bCanToggle && !bIsHidden) ? aTRUETxt : aFALSETxt; - if (bCanToggle && !bIsHidden) - sTmpName = aTRUETxt; - else - sTmpName = aFALSETxt; - - // Database expressions need to be differnt from normal text. Therefore, normal text is set + // Database expressions need to be different from normal text. Therefore, normal text is set // in quotes. If the latter exist they will be removed. If not, check if potential DB name. // Only if there are two or more dots and no quotes, we assume a database. - if(sTmpName.Len() > 1 && sTmpName.GetChar(0) == '\"' && - sTmpName.GetChar((sTmpName.Len() - 1))== '\"') + if (sTmpName.getLength()>1 && + sTmpName.startsWith("\"") && + sTmpName.endsWith("\"")) { - aContent = sTmpName.Copy(1, sTmpName.Len() - 2); + aContent = sTmpName.copy(1, sTmpName.getLength() - 2); bValid = sal_True; } - else if(sTmpName.Search('\"') == STRING_NOTFOUND && + else if(sTmpName.indexOf('\"')<0 && comphelper::string::getTokenCount(sTmpName, '.') > 2) { - ::ReplacePoint(sTmpName); - if(sTmpName.GetChar(0) == '[' && sTmpName.GetChar(sTmpName.Len()-1) == ']') + sTmpName = ::ReplacePoint(sTmpName); + if(sTmpName.startsWith("[") && sTmpName.endsWith("]")) { // remove brackets - sTmpName.Erase(0, 1); - sTmpName.Erase(sTmpName.Len()-1, 1); + sTmpName = sTmpName.copy(1, sTmpName.getLength() - 2); } if( pMgr) { - String sDBName( GetDBName( sTmpName, pDoc )); - String sDataSource(sDBName.GetToken(0, DB_DELIM)); - String sDataTableOrQuery(sDBName.GetToken(1, DB_DELIM)); - if( pMgr->IsInMerge() && sDBName.Len() && + OUString sDBName( GetDBName( sTmpName, pDoc )); + OUString sDataSource(sDBName.getToken(0, DB_DELIM)); + OUString sDataTableOrQuery(sDBName.getToken(1, DB_DELIM)); + if( pMgr->IsInMerge() && !sDBName.isEmpty() && pMgr->IsDataSourceOpen( sDataSource, sDataTableOrQuery, sal_False)) { @@ -1415,26 +1405,22 @@ void SwHiddenTxtField::Evaluate(SwDoc* pDoc) GetLanguage(), aContent, &fNumber, &nTmpFormat ); bValid = sal_True; } - else if( sDBName.Len() && sDataSource.Len() && - sDataTableOrQuery.Len() ) + else if( !sDBName.isEmpty() && !sDataSource.isEmpty() && + !sDataTableOrQuery.isEmpty() ) bValid = sal_True; } } } } -String SwHiddenTxtField::GetFieldName() const +OUString SwHiddenTxtField::GetFieldName() const { - String aStr(SwFieldType::GetTypeStr(nSubType)); - aStr += ' '; - aStr += aCond; - aStr += ' '; - aStr += aTRUETxt; + OUString aStr = SwFieldType::GetTypeStr(nSubType) + + " " + aCond + " " + aTRUETxt; if (nSubType == TYP_CONDTXTFLD) { - aStr.AppendAscii(" : "); - aStr += aFALSETxt; + aStr += " : " + aFALSETxt; } return aStr; } @@ -1456,10 +1442,10 @@ SwField* SwHiddenTxtField::Copy() const void SwHiddenTxtField::SetPar1(const OUString& rStr) { aCond = rStr; - bCanToggle = aCond.getLength() > 0; + bCanToggle = !aCond.isEmpty(); } -const OUString& SwHiddenTxtField::GetPar1() const +OUString SwHiddenTxtField::GetPar1() const { return aCond; } @@ -1485,13 +1471,11 @@ void SwHiddenTxtField::SetPar2(const OUString& rStr) /// get True/False text OUString SwHiddenTxtField::GetPar2() const { - String aRet(aTRUETxt); - if(nSubType == TYP_CONDTXTFLD) + if(nSubType != TYP_CONDTXTFLD) { - aRet += '|'; - aRet += aFALSETxt; + return aTRUETxt; } - return aRet; + return aTRUETxt + "|" + aFALSETxt; } sal_uInt16 SwHiddenTxtField::GetSubType() const @@ -1501,20 +1485,19 @@ sal_uInt16 SwHiddenTxtField::GetSubType() const bool SwHiddenTxtField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const { - const OUString* pOut = 0; switch( nWhichId ) { case FIELD_PROP_PAR1: - pOut = &aCond; + rAny <<= aCond; break; case FIELD_PROP_PAR2: - pOut = &aTRUETxt; + rAny <<= aTRUETxt; break; case FIELD_PROP_PAR3: - pOut = &aFALSETxt; + rAny <<= aFALSETxt; break; case FIELD_PROP_PAR4 : - pOut = &aContent; + rAny <<= aContent; break; case FIELD_PROP_BOOL1: { @@ -1525,8 +1508,6 @@ bool SwHiddenTxtField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const default: OSL_FAIL("illegal property"); } - if( pOut ) - rAny <<= *pOut; return true; } @@ -1560,34 +1541,32 @@ bool SwHiddenTxtField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) return true; } -String SwHiddenTxtField::GetColumnName(const String& rName) +OUString SwHiddenTxtField::GetColumnName(const OUString& rName) { - sal_uInt16 nPos = rName.Search(DB_DELIM); - if( STRING_NOTFOUND != nPos ) + sal_Int32 nPos = rName.indexOf(DB_DELIM); + if( nPos>=0 ) { - nPos = rName.Search(DB_DELIM, nPos + 1); + nPos = rName.indexOf(DB_DELIM, nPos + 1); - if( STRING_NOTFOUND != nPos ) - return rName.Copy(nPos + 1); + if( nPos>=0 ) + return rName.copy(nPos + 1); } return rName; } -String SwHiddenTxtField::GetDBName(const String& rName, SwDoc *pDoc) +OUString SwHiddenTxtField::GetDBName(const OUString& rName, SwDoc *pDoc) { - sal_uInt16 nPos = rName.Search(DB_DELIM); - if( STRING_NOTFOUND != nPos ) + sal_Int32 nPos = rName.indexOf(DB_DELIM); + if( nPos>=0 ) { - nPos = rName.Search(DB_DELIM, nPos + 1); + nPos = rName.indexOf(DB_DELIM, nPos + 1); - if( STRING_NOTFOUND != nPos ) - return rName.Copy( 0, nPos ); + if( nPos>=0 ) + return rName.copy(0, nPos); } + SwDBData aData = pDoc->GetDBData(); - String sRet = aData.sDataSource; - sRet += DB_DELIM; - sRet += String(aData.sCommand); - return sRet; + return aData.sDataSource + OUString(DB_DELIM) + aData.sCommand; } // field type for line height 0 @@ -1605,15 +1584,15 @@ SwFieldType* SwHiddenParaFieldType::Copy() const // field for line height 0 -SwHiddenParaField::SwHiddenParaField(SwHiddenParaFieldType* pTyp, const String& rStr) +SwHiddenParaField::SwHiddenParaField(SwHiddenParaFieldType* pTyp, const OUString& rStr) : SwField(pTyp), aCond(rStr) { bIsHidden = sal_False; } -String SwHiddenParaField::Expand() const +OUString SwHiddenParaField::Expand() const { - return aEmptyStr; + return OUString(); } SwField* SwHiddenParaField::Copy() const @@ -1629,7 +1608,7 @@ bool SwHiddenParaField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const switch ( nWhichId ) { case FIELD_PROP_PAR1: - rAny <<= OUString(aCond); + rAny <<= aCond; break; case FIELD_PROP_BOOL1: { @@ -1667,7 +1646,7 @@ void SwHiddenParaField::SetPar1(const OUString& rStr) aCond = rStr; } -const OUString& SwHiddenParaField::GetPar1() const +OUString SwHiddenParaField::GetPar1() const { return aCond; } @@ -1686,8 +1665,19 @@ SwFieldType* SwPostItFieldType::Copy() const // PostIt field SwPostItField::SwPostItField( SwPostItFieldType* pT, - const String& rAuthor, const String& rTxt, const String& rInitials, const String& rName, const DateTime& rDateTime ) - : SwField( pT ), sTxt( rTxt ), sAuthor( rAuthor ), sInitials( rInitials ), sName( rName ), aDateTime( rDateTime ), mpText(0), m_pTextObject(0) + const OUString& rAuthor, + const OUString& rTxt, + const OUString& rInitials, + const OUString& rName, + const DateTime& rDateTime ) + : SwField( pT ) + , sTxt( rTxt ) + , sAuthor( rAuthor ) + , sInitials( rInitials ) + , sName( rName ) + , aDateTime( rDateTime ) + , mpText(0) + , m_pTextObject(0) { } @@ -1724,13 +1714,13 @@ const SwFmtFld* SwPostItField::GetByName(SwDoc* pDoc, const OUString& rName) return 0; } -String SwPostItField::Expand() const +OUString SwPostItField::Expand() const { - return aEmptyStr; + return OUString(); } -String SwPostItField::GetDescription() const +OUString SwPostItField::GetDescription() const { return SW_RES(STR_NOTE); } @@ -1751,7 +1741,7 @@ void SwPostItField::SetPar1(const OUString& rStr) } /// get author -const OUString& SwPostItField::GetPar1() const +OUString SwPostItField::GetPar1() const { return sAuthor; } @@ -1768,7 +1758,7 @@ OUString SwPostItField::GetPar2() const return sTxt; } -const OUString& SwPostItField::GetInitials() const +OUString SwPostItField::GetInitials() const { return sInitials; } @@ -1778,7 +1768,7 @@ void SwPostItField::SetName(const OUString& rName) sName = rName; } -const OUString& SwPostItField::GetName() const +OUString SwPostItField::GetName() const { return sName; } @@ -1804,18 +1794,18 @@ bool SwPostItField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const switch( nWhichId ) { case FIELD_PROP_PAR1: - rAny <<= OUString(sAuthor); + rAny <<= sAuthor; break; case FIELD_PROP_PAR2: { - rAny <<= OUString(sTxt); + rAny <<= sTxt; break; } case FIELD_PROP_PAR3: - rAny <<= OUString(sInitials); + rAny <<= sInitials; break; case FIELD_PROP_PAR4: - rAny <<= OUString(sName); + rAny <<= sName; break; case FIELD_PROP_TEXT: { @@ -1930,9 +1920,8 @@ SwFieldType* SwExtUserFieldType::Copy() const return pTyp; } -String SwExtUserFieldType::Expand(sal_uInt16 nSub, sal_uInt32 ) const +OUString SwExtUserFieldType::Expand(sal_uInt16 nSub, sal_uInt32 ) const { - String aRet; sal_uInt16 nRet = USHRT_MAX; switch(nSub) { @@ -1959,9 +1948,9 @@ String SwExtUserFieldType::Expand(sal_uInt16 nSub, sal_uInt32 ) const if( USHRT_MAX != nRet ) { SvtUserOptions& rUserOpt = SW_MOD()->GetUserOptions(); - aRet = rUserOpt.GetToken( nRet ); + return rUserOpt.GetToken( nRet ); } - return aRet; + return OUString(); } // extended user information field @@ -1972,7 +1961,7 @@ SwExtUserField::SwExtUserField(SwExtUserFieldType* pTyp, sal_uInt16 nSubTyp, sal aContent = ((SwExtUserFieldType*)GetTyp())->Expand(nType, GetFormat()); } -String SwExtUserField::Expand() const +OUString SwExtUserField::Expand() const { if (!IsFixed()) ((SwExtUserField*)this)->aContent = ((SwExtUserFieldType*)GetTyp())->Expand(nType, GetFormat()); @@ -2003,7 +1992,7 @@ bool SwExtUserField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const switch( nWhichId ) { case FIELD_PROP_PAR1: - rAny <<= OUString(aContent); + rAny <<= aContent; break; case FIELD_PROP_USHORT1: @@ -2029,7 +2018,7 @@ bool SwExtUserField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) switch( nWhichId ) { case FIELD_PROP_PAR1: - ::GetString( rAny, aContent ); + rAny >>= aContent; break; case FIELD_PROP_USHORT1: @@ -2076,9 +2065,9 @@ SwRefPageSetField::SwRefPageSetField( SwRefPageSetFieldType* pTyp, { } -String SwRefPageSetField::Expand() const +OUString SwRefPageSetField::Expand() const { - return aEmptyStr; + return OUString(); } SwField* SwRefPageSetField::Copy() const @@ -2213,7 +2202,7 @@ void SwRefPageGetFieldType::UpdateField( SwTxtFld* pTxtFld, _SetGetExpFlds& rSetList ) { SwRefPageGetField* pGetFld = (SwRefPageGetField*)pTxtFld->GetFld().GetFld(); - pGetFld->SetText( aEmptyStr ); + pGetFld->SetText( OUString() ); // then search the correct RefPageSet field SwTxtNode* pTxtNode = (SwTxtNode*)&pTxtFld->GetTxtNode(); @@ -2265,7 +2254,7 @@ SwRefPageGetField::SwRefPageGetField( SwRefPageGetFieldType* pTyp, { } -String SwRefPageGetField::Expand() const +OUString SwRefPageGetField::Expand() const { return sTxt; } @@ -2289,7 +2278,7 @@ void SwRefPageGetField::ChangeExpansion( const SwFrm* pFrm, pDoc->GetNodes().GetEndOfExtras().GetIndex() ) return; - sTxt.Erase(); + sTxt = OUString(); OSL_ENSURE( !pFrm->IsInDocBody(), "Flag incorrect, frame is in DocBody" ); @@ -2344,7 +2333,7 @@ bool SwRefPageGetField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const rAny <<= (sal_Int16)GetFormat(); break; case FIELD_PROP_PAR1: - rAny <<= OUString(sTxt); + rAny <<= sTxt; break; default: OSL_FAIL("illegal property"); @@ -2367,11 +2356,7 @@ bool SwRefPageGetField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) } break; case FIELD_PROP_PAR1: - { - OUString sTmp; - rAny >>= sTmp; - sTxt = sTmp; - } + rAny >>= sTxt; break; default: OSL_FAIL("illegal property"); @@ -2403,15 +2388,14 @@ SwCharFmt* SwJumpEditFieldType::GetCharFmt() } SwJumpEditField::SwJumpEditField( SwJumpEditFieldType* pTyp, sal_uInt32 nForm, - const String& rTxt, const String& rHelp ) + const OUString& rTxt, const OUString& rHelp ) : SwField( pTyp, nForm ), sTxt( rTxt ), sHelp( rHelp ) { } -String SwJumpEditField::Expand() const +OUString SwJumpEditField::Expand() const { - return OUStringBuffer().append('<'). - append(sTxt).append('>').makeStringAndClear(); + return "<" + sTxt + ">"; } SwField* SwJumpEditField::Copy() const @@ -2421,7 +2405,7 @@ SwField* SwJumpEditField::Copy() const } /// get place holder text -const OUString& SwJumpEditField::GetPar1() const +OUString SwJumpEditField::GetPar1() const { return sTxt; } @@ -2464,10 +2448,10 @@ bool SwJumpEditField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const } break; case FIELD_PROP_PAR1 : - rAny <<= OUString(sHelp); + rAny <<= sHelp; break; case FIELD_PROP_PAR2 : - rAny <<= OUString(sTxt); + rAny <<= sTxt; break; default: OSL_FAIL("illegal property"); @@ -2523,13 +2507,13 @@ SwFieldType* SwCombinedCharFieldType::Copy() const // combined character field SwCombinedCharField::SwCombinedCharField( SwCombinedCharFieldType* pFTyp, - const String& rChars ) + const OUString& rChars ) : SwField( pFTyp, 0 ), - sCharacters( rChars.Copy( 0, MAX_COMBINED_CHARACTERS )) + sCharacters( rChars.copy( 0, MAX_COMBINED_CHARACTERS )) { } -String SwCombinedCharField::Expand() const +OUString SwCombinedCharField::Expand() const { return sCharacters; } @@ -2540,7 +2524,7 @@ SwField* SwCombinedCharField::Copy() const sCharacters ); } -const OUString& SwCombinedCharField::GetPar1() const +OUString SwCombinedCharField::GetPar1() const { return sCharacters; } @@ -2556,7 +2540,7 @@ bool SwCombinedCharField::QueryValue( uno::Any& rAny, switch( nWhichId ) { case FIELD_PROP_PAR1: - rAny <<= OUString( sCharacters ); + rAny <<= sCharacters; break; default: OSL_FAIL("illegal property"); diff --git a/sw/source/core/fields/expfld.cxx b/sw/source/core/fields/expfld.cxx index 65538544b271..388d2feea268 100644 --- a/sw/source/core/fields/expfld.cxx +++ b/sw/source/core/fields/expfld.cxx @@ -96,30 +96,35 @@ static sal_Int32 lcl_APIToSubType(const uno::Any& rAny) return nSet; } -void ReplacePoint( String& rTmpName, bool bWithCommandType ) +OUString ReplacePoint( OUString rTmpName, bool bWithCommandType ) { // replace first and last (if bWithCommandType: last two) dot // since table names may contain dots - xub_StrLen nLen = rTmpName.Len(); - sal_Unicode *pStr = rTmpName.GetBufferAccess(), *pBackStr = pStr + nLen; + sal_Int32 nIndex = rTmpName.lastIndexOf('.'); + if (nIndex<0) + { + return rTmpName; + } - long nBackCount = bWithCommandType ? 2 : 1; - xub_StrLen i; + OUString sRes = rTmpName.replaceAt(nIndex, 1, OUString(DB_DELIM)); - for( i = nLen; i; --i, pBackStr-- ) - if( '.' == *pBackStr ) - { - *pBackStr = DB_DELIM; - if(!--nBackCount) - break; - } - for( i = 0; i < nLen; ++i, ++pStr ) - if( '.' == *pStr ) + if (bWithCommandType) + { + nIndex = sRes.lastIndexOf('.', nIndex); + if (nIndex<0) { - *pStr = DB_DELIM; - break; + return sRes; } + sRes = sRes.replaceAt(nIndex, 1, OUString(DB_DELIM)); + } + + nIndex = sRes.indexOf('.'); + if (nIndex>=0) + { + sRes = sRes.replaceAt(nIndex, 1, OUString(DB_DELIM)); + } + return sRes; } SwTxtNode* GetFirstTxtNode( const SwDoc& rDoc, SwPosition& rPos, @@ -267,7 +272,7 @@ void SwGetExpFieldType::Modify( const SfxPoolItem*, const SfxPoolItem* pNew ) // do not expand anything else } -SwGetExpField::SwGetExpField(SwGetExpFieldType* pTyp, const String& rFormel, +SwGetExpField::SwGetExpField(SwGetExpFieldType* pTyp, const OUString& rFormel, sal_uInt16 nSub, sal_uLong nFmt) : SwFormulaField( pTyp, nFmt, 0.0 ), bIsInBodyTxt( sal_True ), @@ -277,23 +282,22 @@ SwGetExpField::SwGetExpField(SwGetExpFieldType* pTyp, const String& rFormel, SetFormula( rFormel ); } -String SwGetExpField::Expand() const +OUString SwGetExpField::Expand() const { if(nSubType & nsSwExtendedSubType::SUB_CMD) return GetFormula(); - else - return sExpand; + + return sExpand; } -String SwGetExpField::GetFieldName() const +OUString SwGetExpField::GetFieldName() const { - String aStr( SwFieldType::GetTypeStr( - static_cast(((nsSwGetSetExpType::GSE_FORMULA & nSubType) != 0) - ? TYP_FORMELFLD - : TYP_GETFLD ) )); - aStr += ' '; - aStr += GetFormula(); - return aStr; + const sal_uInt16 nType = static_cast( + (nsSwGetSetExpType::GSE_FORMULA & nSubType) + ? TYP_FORMELFLD + : TYP_GETFLD); + + return SwFieldType::GetTypeStr(nType) + " " + GetFormula(); } SwField* SwGetExpField::Copy() const @@ -349,7 +353,7 @@ void SwGetExpField::ChangeExpansion( const SwFrm& rFrm, const SwTxtFld& rFld ) SwHash** ppHashTbl; sal_uInt16 nSize; rDoc.FldsToExpand( ppHashTbl, nSize, aEndFld ); - LookString( ppHashTbl, nSize, GetFormula(), sExpand ); + sExpand = LookString( ppHashTbl, nSize, GetFormula() ); ::DeleteHashTable( ppHashTbl, nSize ); } else @@ -409,7 +413,7 @@ bool SwGetExpField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const rAny <<= (sal_Int16)nSubType; break; case FIELD_PROP_PAR1: - rAny <<= OUString( GetFormula() ); + rAny <<= GetFormula(); break; case FIELD_PROP_SUBTYPE: { @@ -424,7 +428,7 @@ bool SwGetExpField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const } break; case FIELD_PROP_PAR4: - rAny <<= OUString(GetExpStr()); + rAny <<= GetExpStr(); break; default: return SwField::QueryValue(rAny, nWhichId); @@ -435,7 +439,6 @@ bool SwGetExpField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const bool SwGetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) { sal_Int32 nTmp = 0; - String sTmp; switch( nWhichId ) { case FIELD_PROP_DOUBLE: @@ -450,8 +453,12 @@ bool SwGetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) nSubType = static_cast(nTmp); break; case FIELD_PROP_PAR1: - SetFormula( ::GetString( rAny, sTmp )); + { + OUString sTmp; + rAny >>= sTmp; + SetFormula(sTmp); break; + } case FIELD_PROP_SUBTYPE: nTmp = lcl_APIToSubType(rAny); if( nTmp >=0 ) @@ -464,19 +471,23 @@ bool SwGetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) nSubType &= (~nsSwExtendedSubType::SUB_CMD); break; case FIELD_PROP_PAR4: - ChgExpStr(::GetString( rAny, sTmp )); + { + OUString sTmp; + rAny >>= sTmp; + ChgExpStr(sTmp); break; + } default: return SwField::PutValue(rAny, nWhichId); } return true; } -SwSetExpFieldType::SwSetExpFieldType( SwDoc* pDc, const String& rName, sal_uInt16 nTyp ) +SwSetExpFieldType::SwSetExpFieldType( SwDoc* pDc, const OUString& rName, sal_uInt16 nTyp ) : SwValueFieldType( pDc, RES_SETEXPFLD ), sName( rName ), pOutlChgNd( 0 ), - sDelim( OUString(".") ), + sDelim( "." ), nType(nTyp), nLevel( UCHAR_MAX ), bDeleted( sal_False ) { @@ -494,7 +505,7 @@ SwFieldType* SwSetExpFieldType::Copy() const return pNew; } -const OUString& SwSetExpFieldType::GetName() const +OUString SwSetExpFieldType::GetName() const { return sName; } @@ -598,10 +609,10 @@ void SwSetExpFieldType::SetChapter( SwSetExpField& rFld, const SwNode& rNd ) const SwNodeNum & aNum = *(pTxtNd->GetNum()); // nur die Nummer besorgen, ohne Pre-/Post-fixstrings - String sNumber( pRule->MakeNumString(aNum, sal_False )); + OUString sNumber( pRule->MakeNumString(aNum, sal_False )); - if( sNumber.Len() ) - rFld.ChgExpStr( ( sNumber += sDelim ) += rFld.GetExpStr() ); + if( !sNumber.isEmpty() ) + rFld.ChgExpStr( sNumber + sDelim + rFld.GetExpStr() ); } else { @@ -622,7 +633,7 @@ bool SwSetExpFieldType::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const } break; case FIELD_PROP_PAR2: - rAny <<= OUString(GetDelimiter()); + rAny <<= GetDelimiter(); break; case FIELD_PROP_SHORT1: { @@ -649,11 +660,12 @@ bool SwSetExpFieldType::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) break; case FIELD_PROP_PAR2: { - String sTmp; - if( ::GetString( rAny, sTmp ).Len() ) + OUString sTmp; + rAny >>= sTmp; + if( !sTmp.isEmpty() ) SetDelimiter( sTmp ); else - SetDelimiter(OUString(" ")); + SetDelimiter( " " ); } break; case FIELD_PROP_SHORT1: @@ -674,13 +686,16 @@ bool SwSetExpFieldType::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) bool SwSeqFldList::InsertSort( _SeqFldLstElem* pNew ) { - sal_Unicode* p = pNew->sDlgEntry.GetBufferAccess(); - while( *p ) + OUStringBuffer aBuf(pNew->sDlgEntry); + const sal_Int32 nLen = aBuf.getLength(); + for (sal_Int32 i = 0; i < nLen; ++i) { - if( *p < 0x20 ) - *p = 0x20; - ++p; + if (aBuf[i]<' ') + { + aBuf[i]=' '; + } } + pNew->sDlgEntry = aBuf.makeStringAndClear(); sal_uInt16 nPos; bool bRet = SeekEntry( *pNew, &nPos ); @@ -699,11 +714,11 @@ bool SwSeqFldList::SeekEntry( const _SeqFldLstElem& rNew, sal_uInt16* pP ) const const CharClass& rCC = GetAppCharClass(); //#59900# Sorting should sort number correctly (e.g. "10" after "9" not after "1") - const String& rTmp2 = rNew.sDlgEntry; + const OUString rTmp2 = rNew.sDlgEntry; sal_Int32 nFndPos2 = 0; - String sNum2( rTmp2.GetToken( 0, ' ', nFndPos2 )); + const OUString sNum2( rTmp2.getToken( 0, ' ', nFndPos2 )); sal_Bool bIsNum2IsNumeric = rCC.isAsciiNumeric( sNum2 ); - sal_Int32 nNum2 = bIsNum2IsNumeric ? sNum2.ToInt32() : 0; + sal_Int32 nNum2 = bIsNum2IsNumeric ? sNum2.toInt32() : 0; nO--; while( nU <= nO ) @@ -711,18 +726,18 @@ bool SwSeqFldList::SeekEntry( const _SeqFldLstElem& rNew, sal_uInt16* pP ) const nM = nU + ( nO - nU ) / 2; //#59900# Sorting should sort number correctly (e.g. "10" after "9" not after "1") - const String& rTmp1 = maData[nM]->sDlgEntry; + const OUString rTmp1 = maData[nM]->sDlgEntry; sal_Int32 nFndPos1 = 0; - String sNum1( rTmp1.GetToken( 0, ' ', nFndPos1 )); + const OUString sNum1( rTmp1.getToken( 0, ' ', nFndPos1 )); sal_Int32 nCmp; if( bIsNum2IsNumeric && rCC.isNumeric( sNum1 ) ) { - sal_Int32 nNum1 = sNum1.ToInt32(); + sal_Int32 nNum1 = sNum1.toInt32(); nCmp = nNum2 - nNum1; if( 0 == nCmp ) - nCmp = rCaseColl.compareString( rTmp2.Copy( nFndPos2 ), - rTmp1.Copy( nFndPos1 )); + nCmp = rCaseColl.compareString( rTmp2.copy( nFndPos2 ), + rTmp1.copy( nFndPos1 )); } else nCmp = rColl.compareString( rTmp2, rTmp1 ); @@ -744,7 +759,7 @@ bool SwSeqFldList::SeekEntry( const _SeqFldLstElem& rNew, sal_uInt16* pP ) const return false; } -SwSetExpField::SwSetExpField(SwSetExpFieldType* pTyp, const String& rFormel, +SwSetExpField::SwSetExpField(SwSetExpFieldType* pTyp, const OUString& rFormel, sal_uLong nFmt) : SwFormulaField( pTyp, nFmt, 0.0 ), nSeqNo( USHRT_MAX ), nSubType(0) @@ -755,35 +770,28 @@ SwSetExpField::SwSetExpField(SwSetExpFieldType* pTyp, const String& rFormel, if( IsSequenceFld() ) { SwValueField::SetValue(1.0); - if( !rFormel.Len() ) + if( rFormel.isEmpty() ) { - String sFormel(rFormel); - sFormel += pTyp->GetName(); - sFormel += '+'; - sFormel += '1'; - SetFormula(sFormel); + SetFormula(pTyp->GetName() + "+1"); } } } -String SwSetExpField::Expand() const +OUString SwSetExpField::Expand() const { - String aStr; if (nSubType & nsSwExtendedSubType::SUB_CMD) { // we need the CommandString - aStr = GetTyp()->GetName(); - aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " = " )); - aStr += GetFormula(); + return GetTyp()->GetName() + " = " + GetFormula(); } - else if(!(nSubType & nsSwExtendedSubType::SUB_INVISIBLE)) + if(!(nSubType & nsSwExtendedSubType::SUB_INVISIBLE)) { // value is visible - aStr = sExpand; + return sExpand; } - return aStr; + return OUString(); } /// @return the field name -String SwSetExpField::GetFieldName() const +OUString SwSetExpField::GetFieldName() const { SwFldTypesEnum const nStrType( (IsSequenceFld()) ? TYP_SEQFLD @@ -791,15 +799,15 @@ String SwSetExpField::GetFieldName() const ? TYP_SETINPFLD : TYP_SETFLD ); - String aStr( SwFieldType::GetTypeStr( static_cast(nStrType) ) ); - aStr += ' '; - aStr += GetTyp()->GetName(); + OUString aStr( + SwFieldType::GetTypeStr( static_cast(nStrType) ) + + " " + + GetTyp()->GetName() ); // Sequence: without formula if (TYP_SEQFLD != nStrType) { - aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " = " ) ); - aStr += GetFormula(); + aStr += " = " + GetFormula(); } return aStr; } @@ -865,10 +873,12 @@ xub_StrLen SwGetExpField::GetReferenceTextPos( const SwFmtFld& rFmt, SwDoc& rDoc const SwTxtNode& rTxtNode = pTxtFld->GetTxtNode(); // xub_StrLen nRet = nHint ? nHint : *pTxtFld->GetStart() + 1; - String sNodeText = rTxtNode.GetTxt(); - sNodeText.Erase(0, nRet); - if(sNodeText.Len()) + OUString sNodeText = rTxtNode.GetTxt(); + + if(nRetGetRealScriptOfText( sNodeText, 0 ); @@ -892,26 +902,26 @@ xub_StrLen SwGetExpField::GetReferenceTextPos( const SwFmtFld& rFmt, SwDoc& rDoc GetWhichOfScript( RES_CHRATR_LANGUAGE, nSrcpt )) ).GetLanguage(); LanguageTag aLanguageTag( eLang); CharClass aCC( aLanguageTag); - sal_Unicode c0 = sNodeText.GetChar(0); + sal_Unicode c0 = sNodeText[0]; sal_Bool bIsAlphaNum = aCC.isAlphaNumeric( sNodeText, 0 ); if( !bIsAlphaNum || (c0 == ' ' || c0 == '\t')) { // ignoring blanks nRet++; - unsigned i = 1; - while (i < sNodeText.Len() && - (sNodeText.GetChar(i) == ' ' || - sNodeText.GetChar(i) == '\t') + const sal_Int32 nLen = sNodeText.getLength(); + for (sal_Int32 i = 1; + iGetName(); } @@ -949,20 +959,18 @@ SwFieldType* SwInputFieldType::Copy() const return pType; } -SwInputField::SwInputField(SwInputFieldType* pTyp, const String& rContent, - const String& rPrompt, sal_uInt16 nSub, sal_uLong nFmt) : +SwInputField::SwInputField(SwInputFieldType* pTyp, const OUString& rContent, + const OUString& rPrompt, sal_uInt16 nSub, sal_uLong nFmt) : SwField(pTyp, nFmt), aContent(rContent), aPText(rPrompt), nSubType(nSub) { } -String SwInputField::GetFieldName() const +OUString SwInputField::GetFieldName() const { - String aStr(SwField::GetFieldName()); + OUString aStr(SwField::GetFieldName()); if ((nSubType & 0x00ff) == INP_USR) { - aStr += GetTyp()->GetName(); - aStr += ' '; - aStr += aContent; + aStr += GetTyp()->GetName() + " " + aContent; } return aStr; } @@ -979,21 +987,21 @@ SwField* SwInputField::Copy() const return pFld; } -String SwInputField::Expand() const +OUString SwInputField::Expand() const { - String sRet; if((nSubType & 0x00ff) == INP_TXT) - sRet = aContent; + return aContent; - else if( (nSubType & 0x00ff) == INP_USR ) + if( (nSubType & 0x00ff) == INP_USR ) { SwUserFieldType* pUserTyp = (SwUserFieldType*) ((SwInputFieldType*)GetTyp())->GetDoc()-> GetFldType( RES_USERFLD, aContent, false ); if( pUserTyp ) - sRet = pUserTyp->GetContent(); + return pUserTyp->GetContent(); } - return sRet; + + return OUString(); } bool SwInputField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const @@ -1001,16 +1009,16 @@ bool SwInputField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const switch( nWhichId ) { case FIELD_PROP_PAR1: - rAny <<= OUString( aContent ); + rAny <<= aContent; break; case FIELD_PROP_PAR2: - rAny <<= OUString( aPText ); + rAny <<= aPText; break; case FIELD_PROP_PAR3: - rAny <<= OUString( aHelp ); + rAny <<= aHelp; break; case FIELD_PROP_PAR4: - rAny <<= OUString( aToolTip ); + rAny <<= aToolTip; break; default: OSL_FAIL("illegal property"); @@ -1023,16 +1031,16 @@ bool SwInputField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) switch( nWhichId ) { case FIELD_PROP_PAR1: - rAny >>= aContent; + rAny >>= aContent; break; case FIELD_PROP_PAR2: - ::GetString( rAny, aPText ); + rAny >>= aPText; break; case FIELD_PROP_PAR3: - ::GetString( rAny, aHelp ); + rAny >>= aHelp; break; case FIELD_PROP_PAR4: - ::GetString( rAny, aToolTip ); + rAny >>= aToolTip; break; default: OSL_FAIL("illegal property"); @@ -1046,7 +1054,7 @@ void SwInputField::SetPar1(const OUString& rStr) aContent = rStr; } -const OUString& SwInputField::GetPar1() const +OUString SwInputField::GetPar1() const { return aContent; } @@ -1062,29 +1070,29 @@ OUString SwInputField::GetPar2() const return aPText; } -void SwInputField::SetHelp(const String & rStr) +void SwInputField::SetHelp(const OUString & rStr) { aHelp = rStr; } -String SwInputField::GetHelp() const +OUString SwInputField::GetHelp() const { return aHelp; } -void SwInputField::SetToolTip(const String & rStr) +void SwInputField::SetToolTip(const OUString & rStr) { aToolTip = rStr; } -String SwInputField::GetToolTip() const +OUString SwInputField::GetToolTip() const { return aToolTip; } sal_Bool SwInputField::isFormField() const { - return aHelp.Len() > 0 || aToolTip.Len() > 0; + return !aHelp.isEmpty() || !aToolTip.isEmpty(); } sal_uInt16 SwInputField::GetSubType() const @@ -1120,13 +1128,10 @@ bool SwSetExpField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const rAny <<= OUString ( SwStyleNameMapper::GetProgName(GetPar1(), nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL ) ); break; case FIELD_PROP_PAR2: - { - //I18N - if the formula contains only "TypeName+1" - //and it's one of the initially created sequence fields - //then the localized names has to be replaced by a programmatic name - OUString sMyFormula = SwXFieldMaster::LocalizeFormula(*this, GetFormula(), sal_True); - rAny <<= OUString( sMyFormula ); - } + //I18N - if the formula contains only "TypeName+1" + //and it's one of the initially created sequence fields + //then the localized names has to be replaced by a programmatic name + rAny <<= SwXFieldMaster::LocalizeFormula(*this, GetFormula(), sal_True); break; case FIELD_PROP_DOUBLE: rAny <<= (double)GetValue(); @@ -1139,7 +1144,7 @@ bool SwSetExpField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const } break; case FIELD_PROP_PAR3: - rAny <<= OUString( aPText ); + rAny <<= aPText; break; case FIELD_PROP_BOOL3: { @@ -1154,7 +1159,7 @@ bool SwSetExpField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const } break; case FIELD_PROP_PAR4: - rAny <<= OUString(GetExpStr()); + rAny <<= GetExpStr(); break; default: return SwField::QueryValue(rAny, nWhichId); @@ -1166,7 +1171,6 @@ bool SwSetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) { sal_Int32 nTmp32 = 0; sal_Int16 nTmp16 = 0; - String sTmp; switch( nWhichId ) { case FIELD_PROP_BOOL2: @@ -1193,8 +1197,11 @@ bool SwSetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) nSeqNo = nTmp16; break; case FIELD_PROP_PAR1: - SetPar1( SwStyleNameMapper::GetUIName( - ::GetString( rAny, sTmp ), nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL ) ); + { + OUString sTmp; + rAny >>= sTmp; + SetPar1( SwStyleNameMapper::GetUIName( sTmp, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL ) ); + } break; case FIELD_PROP_PAR2: { @@ -1203,8 +1210,7 @@ bool SwSetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) //I18N - if the formula contains only "TypeName+1" //and it's one of the initially created sequence fields //then the localized names has to be replaced by a programmatic name - OUString sMyFormula = SwXFieldMaster::LocalizeFormula(*this, uTmp, sal_False); - SetFormula( sMyFormula ); + SetFormula( SwXFieldMaster::LocalizeFormula(*this, uTmp, sal_False) ); } break; case FIELD_PROP_DOUBLE: @@ -1220,7 +1226,7 @@ bool SwSetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) SetSubType(static_cast((GetSubType() & 0xff00) | nTmp32)); break; case FIELD_PROP_PAR3: - ::GetString( rAny, aPText ); + rAny >>= aPText; break; case FIELD_PROP_BOOL3: if(*(sal_Bool*) rAny.getValue()) @@ -1232,7 +1238,11 @@ bool SwSetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) SetInputFlag(*(sal_Bool*) rAny.getValue()); break; case FIELD_PROP_PAR4: - ChgExpStr( ::GetString( rAny, sTmp )); + { + OUString sTmp; + rAny >>= sTmp; + ChgExpStr( sTmp ); + } break; default: return SwField::PutValue(rAny, nWhichId); diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx index 9db180b1c47d..e80657c9c051 100644 --- a/sw/source/core/fields/fldbas.cxx +++ b/sw/source/core/fields/fldbas.cxx @@ -68,7 +68,7 @@ static sal_uInt16 lcl_GetLanguageOfFormat( sal_uInt16 nLng, sal_uLong nFmt, // Globals /// field names -std::vector* SwFieldType::pFldNames = 0; +std::vector* SwFieldType::pFldNames = 0; namespace { @@ -118,15 +118,14 @@ namespace } -const String& SwFieldType::GetTypeStr(sal_uInt16 nTypeId) +OUString SwFieldType::GetTypeStr(sal_uInt16 nTypeId) { if( !pFldNames ) _GetFldName(); if( nTypeId < SwFieldType::pFldNames->size() ) return (*SwFieldType::pFldNames)[nTypeId]; - else - return aEmptyStr; + return OUString(); } // each field refences a field type that is unique for each document @@ -136,9 +135,9 @@ SwFieldType::SwFieldType( sal_uInt16 nWhichId ) { } -const OUString& SwFieldType::GetName() const +OUString SwFieldType::GetName() const { - return aEmptyOUStr; + return OUString(); } bool SwFieldType::QueryValue( uno::Any&, sal_uInt16 ) const @@ -221,7 +220,7 @@ sal_uInt16 SwField::GetTypeId() const } /// get name or content -String SwField::GetFieldName() const +OUString SwField::GetFieldName() const { sal_uInt16 nTypeId = GetTypeId(); if (RES_DATETIMEFLD == GetTyp()->Which()) @@ -229,18 +228,17 @@ String SwField::GetFieldName() const nTypeId = static_cast( ((GetSubType() & DATEFLD) != 0) ? TYP_DATEFLD : TYP_TIMEFLD); } - String sRet = SwFieldType::GetTypeStr( nTypeId ); + OUString sRet = SwFieldType::GetTypeStr( nTypeId ); if (IsFixed()) { - sRet += ' '; - sRet += ViewShell::GetShellRes()->aFixedStr; + sRet += " " + OUString(ViewShell::GetShellRes()->aFixedStr); } return sRet; } -const OUString& SwField::GetPar1() const +OUString SwField::GetPar1() const { - return aEmptyOUStr; + return OUString(); } OUString SwField::GetPar2() const @@ -248,7 +246,7 @@ OUString SwField::GetPar2() const return OUString(); } -String SwField::GetFormula() const +OUString SwField::GetFormula() const { return GetPar2(); } @@ -380,7 +378,7 @@ sal_Bool SwField::IsFixed() const return bRet; } -String SwField::ExpandField(bool const bCached) const +OUString SwField::ExpandField(bool const bCached) const { if (!bCached) // #i85766# do not expand fields in clipboard documents { @@ -399,7 +397,7 @@ SwField * SwField::CopyField() const } /// expand numbering -String FormatNumber(sal_uInt32 nNum, sal_uInt32 nFormat) +OUString FormatNumber(sal_uInt32 nNum, sal_uInt32 nFormat) { if(SVX_NUM_PAGEDESC == nFormat) return OUString::number( nNum ); @@ -426,7 +424,7 @@ SwValueFieldType::SwValueFieldType( const SwValueFieldType& rTyp ) } /// return value formatted as string -String SwValueFieldType::ExpandValue( const double& rVal, +OUString SwValueFieldType::ExpandValue( const double& rVal, sal_uInt32 nFmt, sal_uInt16 nLng) const { if (rVal >= DBL_MAX) // error string for calculator @@ -477,19 +475,19 @@ String SwValueFieldType::ExpandValue( const double& rVal, return sExpand; } -String SwValueFieldType::DoubleToString(const double &rVal, +OUString SwValueFieldType::DoubleToString(const double &rVal, sal_uInt32 nFmt) const { SvNumberFormatter* pFormatter = pDoc->GetNumberFormatter(); const SvNumberformat* pEntry = pFormatter->GetEntry(nFmt); if (!pEntry) - return String(); + return OUString(); return DoubleToString(rVal, pEntry->GetLanguage()); } -String SwValueFieldType::DoubleToString( const double &rVal, +OUString SwValueFieldType::DoubleToString( const double &rVal, sal_uInt16 nLng ) const { SvNumberFormatter* pFormatter = pDoc->GetNumberFormatter(); @@ -639,12 +637,12 @@ SwFormulaField::SwFormulaField( const SwFormulaField& rFld ) { } -String SwFormulaField::GetFormula() const +OUString SwFormulaField::GetFormula() const { return sFormula; } -void SwFormulaField::SetFormula(const String& rStr) +void SwFormulaField::SetFormula(const OUString& rStr) { sFormula = rStr; @@ -659,7 +657,7 @@ void SwFormulaField::SetFormula(const String& rStr) } } -void SwFormulaField::SetExpandedFormula( const String& rStr ) +void SwFormulaField::SetExpandedFormula( const OUString& rStr ) { sal_uInt32 nFmt(GetFormat()); @@ -680,7 +678,7 @@ void SwFormulaField::SetExpandedFormula( const String& rStr ) sFormula = rStr; } -String SwFormulaField::GetExpandedFormula() const +OUString SwFormulaField::GetExpandedFormula() const { sal_uInt32 nFmt(GetFormat()); @@ -694,9 +692,7 @@ String SwFormulaField::GetExpandedFormula() const if (pFormatter->IsTextFormat(nFmt)) { OUString sTempIn(((SwValueFieldType *)GetTyp())->DoubleToString(GetValue(), nFmt)); - OUString sTempOut(sFormattedValue); - pFormatter->GetOutputString(sTempIn, nFmt, sTempOut, &pCol); - sFormattedValue = sTempOut; + pFormatter->GetOutputString(sTempIn, nFmt, sFormattedValue, &pCol); } else { @@ -708,7 +704,7 @@ String SwFormulaField::GetExpandedFormula() const return GetFormula(); } -String SwField::GetDescription() const +OUString SwField::GetDescription() const { return SW_RES(STR_FIELD); } diff --git a/sw/source/core/fields/flddat.cxx b/sw/source/core/fields/flddat.cxx index 4b17cb772b77..04cbcbd7cb41 100644 --- a/sw/source/core/fields/flddat.cxx +++ b/sw/source/core/fields/flddat.cxx @@ -57,7 +57,7 @@ SwDateTimeField::SwDateTimeField(SwDateTimeFieldType* pInitType, sal_uInt16 nSub } } -String SwDateTimeField::Expand() const +OUString SwDateTimeField::Expand() const { double fVal; diff --git a/sw/source/core/fields/flddropdown.cxx b/sw/source/core/fields/flddropdown.cxx index 6f6517a1e358..d81d1d8fd3a0 100644 --- a/sw/source/core/fields/flddropdown.cxx +++ b/sw/source/core/fields/flddropdown.cxx @@ -29,8 +29,6 @@ using namespace com::sun::star; using std::vector; -static String aEmptyString; - SwDropDownFieldType::SwDropDownFieldType() : SwFieldType(RES_DROPDOWN) { @@ -61,18 +59,18 @@ SwDropDownField::~SwDropDownField() { } -String SwDropDownField::Expand() const +OUString SwDropDownField::Expand() const { - String sSelect = GetSelectedItem(); - if(!sSelect.Len()) + OUString sSelect = GetSelectedItem(); + if (sSelect.isEmpty()) { vector::const_iterator aIt = aValues.begin(); if ( aIt != aValues.end()) sSelect = *aIt; } // if still no list value is available a default text of 10 spaces is to be set - if(!sSelect.Len()) - sSelect.AppendAscii ( RTL_CONSTASCII_STRINGPARAM (" ")); + if (sSelect.isEmpty()) + sSelect = " "; return sSelect; } @@ -81,7 +79,7 @@ SwField * SwDropDownField::Copy() const return new SwDropDownField(*this); } -const OUString & SwDropDownField::GetPar1() const +OUString SwDropDownField::GetPar1() const { return GetSelectedItem(); } @@ -104,7 +102,7 @@ void SwDropDownField::SetPar2(const OUString & rName) void SwDropDownField::SetItems(const vector & rItems) { aValues = rItems; - aSelectedItem = aEmptyString; + aSelectedItem = OUString(); } void SwDropDownField::SetItems(const uno::Sequence & rItems) @@ -115,7 +113,7 @@ void SwDropDownField::SetItems(const uno::Sequence & rItems) for (int i = 0; i < aCount; i++) aValues.push_back(rItems[i]); - aSelectedItem = aEmptyString; + aSelectedItem = OUString(); } uno::Sequence SwDropDownField::GetItemSequence() const @@ -134,22 +132,22 @@ uno::Sequence SwDropDownField::GetItemSequence() const return aSeq; } -const OUString & SwDropDownField::GetSelectedItem() const +OUString SwDropDownField::GetSelectedItem() const { return aSelectedItem; } -const OUString & SwDropDownField::GetName() const +OUString SwDropDownField::GetName() const { return aName; } -const OUString & SwDropDownField::GetHelp() const +OUString SwDropDownField::GetHelp() const { return aHelp; } -const OUString & SwDropDownField::GetToolTip() const +OUString SwDropDownField::GetToolTip() const { return aToolTip; } @@ -188,16 +186,16 @@ bool SwDropDownField::QueryValue(::uno::Any &rVal, sal_uInt16 nWhich) const switch( nWhich ) { case FIELD_PROP_PAR1: - rVal <<= GetSelectedItem(); + rVal <<= aSelectedItem; break; case FIELD_PROP_PAR2: - rVal <<= GetName(); + rVal <<= aName; break; case FIELD_PROP_PAR3: - rVal <<= GetHelp(); + rVal <<= aHelp; break; case FIELD_PROP_PAR4: - rVal <<= GetToolTip(); + rVal <<= aToolTip; break; case FIELD_PROP_STRINGS: rVal <<= GetItemSequence(); @@ -225,30 +223,15 @@ bool SwDropDownField::PutValue(const uno::Any &rVal, break; case FIELD_PROP_PAR2: - { - OUString aTmpStr; - rVal >>= aTmpStr; - - SetName(aTmpStr); - } + rVal >>= aName; break; case FIELD_PROP_PAR3: - { - OUString aTmpStr; - rVal >>= aTmpStr; - - SetHelp(aTmpStr); - } + rVal >>= aHelp; break; case FIELD_PROP_PAR4: - { - OUString aTmpStr; - rVal >>= aTmpStr; - - SetToolTip(aTmpStr); - } + rVal >>= aToolTip; break; case FIELD_PROP_STRINGS: diff --git a/sw/source/core/fields/macrofld.cxx b/sw/source/core/fields/macrofld.cxx index a073a842d229..0732979c4564 100644 --- a/sw/source/core/fields/macrofld.cxx +++ b/sw/source/core/fields/macrofld.cxx @@ -42,13 +42,13 @@ SwFieldType* SwMacroFieldType::Copy() const SwMacroField::SwMacroField(SwMacroFieldType* pInitType, - const String& rLibAndName, const String& rTxt) : + const OUString& rLibAndName, const OUString& rTxt) : SwField(pInitType), aMacro(rLibAndName), aText(rTxt), bIsScriptURL(sal_False) { bIsScriptURL = isScriptURL(aMacro); } -String SwMacroField::Expand() const +OUString SwMacroField::Expand() const { return aText ; } @@ -58,20 +58,17 @@ SwField* SwMacroField::Copy() const return new SwMacroField((SwMacroFieldType*)GetTyp(), aMacro, aText); } -String SwMacroField::GetFieldName() const +OUString SwMacroField::GetFieldName() const { - String aStr(GetTyp()->GetName()); - aStr += ' '; - aStr += aMacro; - return aStr; + return GetTyp()->GetName() + " " + aMacro; } -String SwMacroField::GetLibName() const +OUString SwMacroField::GetLibName() const { // if it is a Scripting Framework macro return an empty string if (bIsScriptURL) { - return String(); + return OUString(); } if (!aMacro.isEmpty()) @@ -84,11 +81,11 @@ String SwMacroField::GetLibName() const return aMacro.copy(0, nPos); } - OSL_FAIL("No MacroName"); - return aEmptyStr; + OSL_FAIL("No LibName"); + return OUString(); } -String SwMacroField::GetMacroName() const +OUString SwMacroField::GetMacroName() const { if (!aMacro.isEmpty()) { @@ -108,14 +105,14 @@ String SwMacroField::GetMacroName() const } OSL_FAIL("No MacroName"); - return aEmptyStr; + return OUString(); } SvxMacro SwMacroField::GetSvxMacro() const { - if (bIsScriptURL) + if (bIsScriptURL) { - return SvxMacro(aMacro, String(), EXTENDED_STYPE); + return SvxMacro(aMacro, OUString(), EXTENDED_STYPE); } else { @@ -131,7 +128,7 @@ void SwMacroField::SetPar1(const OUString& rStr) } /// Get macro -const OUString& SwMacroField::GetPar1() const +OUString SwMacroField::GetPar1() const { return aMacro; } @@ -153,16 +150,16 @@ bool SwMacroField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const switch( nWhichId ) { case FIELD_PROP_PAR1: - rAny <<= OUString(GetMacroName()); + rAny <<= GetMacroName(); break; case FIELD_PROP_PAR2: - rAny <<= OUString(aText); + rAny <<= aText; break; case FIELD_PROP_PAR3: - rAny <<= OUString(GetLibName()); + rAny <<= GetLibName(); break; case FIELD_PROP_PAR4: - rAny <<= bIsScriptURL ? OUString(GetMacroName()): OUString(); + rAny <<= bIsScriptURL ? GetMacroName() : OUString(); break; default: OSL_FAIL("illegal property"); @@ -200,17 +197,17 @@ bool SwMacroField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) /// create an internally used macro name from the library and macro name parts void SwMacroField::CreateMacroString( OUString& rMacro, - const String& rMacroName, - const String& rLibraryName ) + const OUString& rMacroName, + const OUString& rLibraryName ) { // concatenate library and name; use dot only if both strings have content rMacro = rLibraryName; - if ( rLibraryName.Len() > 0 && rMacroName.Len() > 0 ) + if ( !rLibraryName.isEmpty() && !rMacroName.isEmpty() ) rMacro += OUString('.'); rMacro += rMacroName; } -sal_Bool SwMacroField::isScriptURL( const String& str ) +sal_Bool SwMacroField::isScriptURL( const OUString& str ) { uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx index 19743c5f9514..7bdcc0c1a4e6 100644 --- a/sw/source/core/fields/reffld.cxx +++ b/sw/source/core/fields/reffld.cxx @@ -195,7 +195,7 @@ bool IsFrameBehind( const SwTxtNode& rMyNd, sal_uInt16 nMySttPos, /// get references SwGetRefField::SwGetRefField( SwGetRefFieldType* pFldType, - const String& rSetRef, sal_uInt16 nSubTyp, + const OUString& rSetRef, sal_uInt16 nSubTyp, sal_uInt16 nSeqenceNo, sal_uLong nFmt ) : SwField( pFldType, nFmt ), sSetRefName( rSetRef ), @@ -208,7 +208,7 @@ SwGetRefField::~SwGetRefField() { } -String SwGetRefField::GetDescription() const +OUString SwGetRefField::GetDescription() const { return SW_RES(STR_REFERENCE); } @@ -244,36 +244,33 @@ const SwTxtNode* SwGetRefField::GetReferencedTxtNode() const } // #i85090# -String SwGetRefField::GetExpandedTxtOfReferencedTxtNode() const +OUString SwGetRefField::GetExpandedTxtOfReferencedTxtNode() const { const SwTxtNode* pReferencedTxtNode( GetReferencedTxtNode() ); return pReferencedTxtNode - ? pReferencedTxtNode->GetExpandTxt( 0, STRING_LEN, true, true ) - : aEmptyStr; + ? OUString(pReferencedTxtNode->GetExpandTxt( 0, STRING_LEN, true, true )) + : OUString(); } -String SwGetRefField::Expand() const +OUString SwGetRefField::Expand() const { return sTxt; } -String SwGetRefField::GetFieldName() const +OUString SwGetRefField::GetFieldName() const { - if ( GetTyp()->GetName().getLength() > 0 || sSetRefName.getLength() > 0 ) + const OUString aName = GetTyp()->GetName(); + if ( !aName.isEmpty() || !sSetRefName.isEmpty() ) { - String aStr(GetTyp()->GetName()); - aStr += ' '; - aStr += sSetRefName; - return aStr; + return aName + " " + sSetRefName; } - else - return Expand(); + return Expand(); } // #i81002# - parameter added void SwGetRefField::UpdateField( const SwTxtFld* pFldTxtAttr ) { - sTxt.Erase(); + sTxt = OUString(); SwDoc* pDoc = ((SwGetRefFieldType*)GetTyp())->GetDoc(); // finding the reference target (the number) @@ -396,16 +393,23 @@ void SwGetRefField::UpdateField( const SwTxtFld* pFldTxtAttr ) sTxt = pTxtNd->GetExpandTxt( nStart, nEnd - nStart ); // alle Sonderzeichen entfernen (durch Blanks ersetzen): - if( sTxt.Len() ) + if( !sTxt.isEmpty() ) { sTxt = comphelper::string::remove(sTxt, 0xad); - for( sal_Unicode* p = sTxt.GetBufferAccess(); *p; ++p ) + OUStringBuffer aBuf(sTxt); + const sal_Int32 l = aBuf.getLength(); + for (sal_Int32 i=0; i>= sTmpStr; + SetExpand( sTmpStr ); + } break; case FIELD_PROP_SHORT1: { @@ -741,7 +749,7 @@ void SwGetRefField::ConvertProgrammaticToUIName() if(GetTyp() && REF_SEQUENCEFLD == nSubType) { SwDoc* pDoc = ((SwGetRefFieldType*)GetTyp())->GetDoc(); - const String& rPar1 = GetPar1(); + const OUString rPar1 = GetPar1(); // don't convert when the name points to an existing field type if(!pDoc->GetFldType(RES_SETEXPFLD, rPar1, false)) { @@ -805,7 +813,7 @@ void SwGetRefFieldType::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew NotifyClients( pOld, pNew ); } -SwTxtNode* SwGetRefFieldType::FindAnchor( SwDoc* pDoc, const String& rRefMark, +SwTxtNode* SwGetRefFieldType::FindAnchor( SwDoc* pDoc, const OUString& rRefMark, sal_uInt16 nSubType, sal_uInt16 nSeqNo, sal_uInt16* pStt, sal_uInt16* pEnd ) { @@ -916,7 +924,7 @@ SwTxtNode* SwGetRefFieldType::FindAnchor( SwDoc* pDoc, const String& rRefMark, struct _RefIdsMap { private: - String aName; + OUString aName; std::set aIds; std::set aDstIds; std::map sequencedIds; /// ID numbers sorted by sequence number. @@ -929,11 +937,11 @@ private: sal_uInt16 GetFirstUnusedId( std::set &rIds ); public: - _RefIdsMap( const String& rName ) : aName( rName ), bInit( false ) {} + _RefIdsMap( const OUString& rName ) : aName( rName ), bInit( false ) {} void Check( SwDoc& rDoc, SwDoc& rDestDoc, SwGetRefField& rFld, bool bField ); - String GetName() { return aName; } + OUString GetName() { return aName; } }; typedef boost::ptr_vector<_RefIdsMap> _RefIdsMaps; @@ -1093,7 +1101,7 @@ void SwGetRefFieldType::MergeWithOtherDoc( SwDoc& rDestDoc ) _RefIdsMap* pMap = 0; for( sal_uInt16 n = aFldMap.size(); n; ) { - if( aFldMap[ --n ].GetName().Equals(rRefFld.GetSetRefName()) ) + if( aFldMap[ --n ].GetName()==rRefFld.GetSetRefName() ) { pMap = &aFldMap[ n ]; break; diff --git a/sw/source/core/fields/scrptfld.cxx b/sw/source/core/fields/scrptfld.cxx index 48b367652c08..22ea9db9400f 100644 --- a/sw/source/core/fields/scrptfld.cxx +++ b/sw/source/core/fields/scrptfld.cxx @@ -34,18 +34,18 @@ SwFieldType* SwScriptFieldType::Copy() const } SwScriptField::SwScriptField( SwScriptFieldType* pInitType, - const String& rType, const String& rCode, + const OUString& rType, const OUString& rCode, sal_Bool bURL ) : SwField( pInitType ), sType( rType ), sCode( rCode ), bCodeURL( bURL ) { } -String SwScriptField::GetDescription() const +OUString SwScriptField::GetDescription() const { return SW_RES(STR_SCRIPT); } -String SwScriptField::Expand() const +OUString SwScriptField::Expand() const { return aEmptyStr; } @@ -61,7 +61,7 @@ void SwScriptField::SetPar1( const OUString& rStr ) sType = rStr; } -const OUString& SwScriptField::GetPar1() const +OUString SwScriptField::GetPar1() const { return sType; } @@ -82,10 +82,10 @@ bool SwScriptField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const switch( nWhichId ) { case FIELD_PROP_PAR1: - rAny <<= OUString( sType ); + rAny <<= sType; break; case FIELD_PROP_PAR2: - rAny <<= OUString( sCode ); + rAny <<= sCode; break; case FIELD_PROP_BOOL1: rAny.setValue(&bCodeURL, ::getBooleanCppuType()); diff --git a/sw/source/core/fields/tblcalc.cxx b/sw/source/core/fields/tblcalc.cxx index 3b18763ffa81..2d310a653db0 100644 --- a/sw/source/core/fields/tblcalc.cxx +++ b/sw/source/core/fields/tblcalc.cxx @@ -51,7 +51,7 @@ void SwTblField::CalcField( SwTblCalcPara& rCalcPara ) ChgValid( !rCalcPara.IsStackOverFlow() ); // is the value again valid? } -SwTblField::SwTblField( SwTblFieldType* pInitType, const String& rFormel, +SwTblField::SwTblField( SwTblFieldType* pInitType, const OUString& rFormel, sal_uInt16 nType, sal_uLong nFmt ) : SwValueField( pInitType, nFmt ), SwTableFormula( rFormel ), nSubType(nType) @@ -70,12 +70,9 @@ SwField* SwTblField::Copy() const return pTmp; } -String SwTblField::GetFieldName() const +OUString SwTblField::GetFieldName() const { - String aStr(GetTyp()->GetName()); - aStr += ' '; - aStr += const_cast(this)->GetCommand(); - return aStr; + return GetTyp()->GetName() + " " + const_cast(this)->GetCommand(); } /// search TextNode containing this field @@ -91,7 +88,7 @@ const SwNode* SwTblField::GetNodeOfFormula() const return 0; } -String SwTblField::GetCommand() +OUString SwTblField::GetCommand() { if (EXTRNL_NAME != GetNameType()) { @@ -103,29 +100,24 @@ String SwTblField::GetCommand() } } return (EXTRNL_NAME == GetNameType()) - ? SwTableFormula::GetFormula() - : String(); + ? OUString(SwTableFormula::GetFormula()) + : OUString(); } -String SwTblField::Expand() const +OUString SwTblField::Expand() const { - String aStr; if (nSubType & nsSwExtendedSubType::SUB_CMD) { - aStr = const_cast(this)->GetCommand(); + return const_cast(this)->GetCommand(); } - else + + if(nSubType & nsSwGetSetExpType::GSE_STRING) { - aStr = sExpand; - if(nSubType & nsSwGetSetExpType::GSE_STRING) - { - // es ist ein String - aStr = sExpand; - aStr.Erase( 0,1 ); - aStr.Erase( aStr.Len()-1, 1 ); - } + // es ist ein String + return sExpand.copy(1, sExpand.getLength()-2); } - return aStr; + + return sExpand; } sal_uInt16 SwTblField::GetSubType() const @@ -165,7 +157,7 @@ bool SwTblField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const sal_uInt16 nOldSubType = nSubType; SwTblField* pThis = (SwTblField*)this; pThis->nSubType |= nsSwExtendedSubType::SUB_CMD; - rAny <<= OUString( Expand() ); + rAny <<= Expand(); pThis->nSubType = nOldSubType; } break; @@ -176,7 +168,7 @@ bool SwTblField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const } break; case FIELD_PROP_PAR1: - rAny <<= OUString(GetExpStr()); + rAny <<= GetExpStr(); break; case FIELD_PROP_FORMAT: rAny <<= (sal_Int32)GetFormat(); @@ -190,11 +182,14 @@ bool SwTblField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const bool SwTblField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) { bool bRet = true; - String sTmp; switch ( nWhichId ) { case FIELD_PROP_PAR2: - SetFormula( ::GetString( rAny, sTmp )); + { + OUString sTmp; + rAny >>= sTmp; + SetFormula( sTmp ); + } break; case FIELD_PROP_BOOL1: if(*(sal_Bool*)rAny.getValue()) @@ -203,7 +198,11 @@ bool SwTblField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) nSubType = nsSwGetSetExpType::GSE_FORMULA; break; case FIELD_PROP_PAR1: - ChgExpStr( ::GetString( rAny, sTmp )); + { + OUString sTmp; + rAny >>= sTmp; + ChgExpStr( sTmp ); + } break; case FIELD_PROP_FORMAT: { diff --git a/sw/source/core/fields/usrfld.cxx b/sw/source/core/fields/usrfld.cxx index 21aab3236008..35b726178f9d 100644 --- a/sw/source/core/fields/usrfld.cxx +++ b/sw/source/core/fields/usrfld.cxx @@ -41,13 +41,12 @@ SwUserField::SwUserField(SwUserFieldType* pTyp, sal_uInt16 nSub, sal_uInt32 nFmt { } -String SwUserField::Expand() const +OUString SwUserField::Expand() const { - String sStr; if(!(nSubType & nsSwExtendedSubType::SUB_INVISIBLE)) - sStr = ((SwUserFieldType*)GetTyp())->Expand(GetFormat(), nSubType, GetLanguage()); + return ((SwUserFieldType*)GetTyp())->Expand(GetFormat(), nSubType, GetLanguage()); - return sStr; + return OUString(); } SwField* SwUserField::Copy() const @@ -57,14 +56,11 @@ SwField* SwUserField::Copy() const return pTmp; } -String SwUserField::GetFieldName() const +OUString SwUserField::GetFieldName() const { - String aStr(SwFieldType::GetTypeStr(TYP_USERFLD)); - aStr += ' '; - aStr += GetTyp()->GetName(); - aStr.AppendAscii(" = "); - aStr += static_cast(GetTyp())->GetContent(); - return aStr; + return SwFieldType::GetTypeStr(TYP_USERFLD) + + " " + GetTyp()->GetName() + " = " + + static_cast(GetTyp())->GetContent(); } double SwUserField::GetValue() const @@ -78,7 +74,7 @@ void SwUserField::SetValue( const double& rVal ) } /// Get name -const OUString& SwUserField::GetPar1() const +OUString SwUserField::GetPar1() const { return ((const SwUserFieldType*)GetTyp())->GetName(); } @@ -159,7 +155,7 @@ bool SwUserField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) return true; } -SwUserFieldType::SwUserFieldType( SwDoc* pDocPtr, const String& aNam ) +SwUserFieldType::SwUserFieldType( SwDoc* pDocPtr, const OUString& aNam ) : SwValueFieldType( pDocPtr, RES_USERFLD ), nValue( 0 ), nType(nsSwGetSetExpType::GSE_STRING) @@ -171,18 +167,16 @@ SwUserFieldType::SwUserFieldType( SwDoc* pDocPtr, const String& aNam ) EnableFormat(sal_False); // Do not use a Numberformatter } -String SwUserFieldType::Expand(sal_uInt32 nFmt, sal_uInt16 nSubType, sal_uInt16 nLng) +OUString SwUserFieldType::Expand(sal_uInt32 nFmt, sal_uInt16 nSubType, sal_uInt16 nLng) { - String aStr(aContent); if((nType & nsSwGetSetExpType::GSE_EXPR) && !(nSubType & nsSwExtendedSubType::SUB_CMD)) { EnableFormat(sal_True); - aStr = ExpandValue(nValue, nFmt, nLng); + return ExpandValue(nValue, nFmt, nLng); } - else - EnableFormat(sal_False); // Do not use a Numberformatter - return aStr; + EnableFormat(sal_False); // Do not use a Numberformatter + return aContent; } SwFieldType* SwUserFieldType::Copy() const @@ -197,7 +191,7 @@ SwFieldType* SwUserFieldType::Copy() const return pTmp; } -const OUString& SwUserFieldType::GetName() const +OUString SwUserFieldType::GetName() const { return aName; } @@ -233,7 +227,7 @@ double SwUserFieldType::GetValue( SwCalc& rCalc ) return nValue; } -String SwUserFieldType::GetContent( sal_uInt32 nFmt ) +OUString SwUserFieldType::GetContent( sal_uInt32 nFmt ) { if (nFmt && nFmt != SAL_MAX_UINT32) { @@ -245,11 +239,11 @@ String SwUserFieldType::GetContent( sal_uInt32 nFmt ) pFormatter->GetOutputString(GetValue(), nFmt, sFormattedValue, &pCol); return sFormattedValue; } - else - return aContent; + + return aContent; } -void SwUserFieldType::SetContent( const String& rStr, sal_uInt32 nFmt ) +void SwUserFieldType::SetContent( const OUString& rStr, sal_uInt32 nFmt ) { if( aContent != rStr ) { @@ -285,7 +279,7 @@ bool SwUserFieldType::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const rAny <<= (double) nValue; break; case FIELD_PROP_PAR2: - rAny <<= OUString(aContent); + rAny <<= aContent; break; case FIELD_PROP_BOOL1: { @@ -316,7 +310,7 @@ bool SwUserFieldType::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) } break; case FIELD_PROP_PAR2: - ::GetString( rAny, aContent ); + rAny >>= aContent; break; case FIELD_PROP_BOOL1: if(*(sal_Bool*)rAny.getValue()) diff --git a/sw/source/core/inc/docfld.hxx b/sw/source/core/inc/docfld.hxx index f30a366a7199..906d21d4d09a 100644 --- a/sw/source/core/inc/docfld.hxx +++ b/sw/source/core/inc/docfld.hxx @@ -133,8 +133,8 @@ struct SwCalcFldType : public SwHash }; // search for the string that was saved under rName in the hash table -void LookString( SwHash** ppTbl, sal_uInt16 nSize, const String& rName, - String& rRet, sal_uInt16* pPos = 0 ); +OUString LookString( SwHash** ppTbl, sal_uInt16 nSize, const OUString& rName, + sal_uInt16* pPos = 0 ); const int GETFLD_ALL = 3; // combine flags via OR const int GETFLD_CALC = 1; -- cgit v1.2.3