From 3b82a237ff0d31574fca5fbf9a9ce6482afa596b Mon Sep 17 00:00:00 2001 From: Matteo Casalin Date: Thu, 15 Aug 2013 21:13:04 +0200 Subject: String to OUString Change-Id: I0c4a87e49097c3fa1de46f6aff337c2fbaa63718 Reviewed-on: https://gerrit.libreoffice.org/5443 Reviewed-by: Michael Stahl Tested-by: Michael Stahl --- sw/inc/doc.hxx | 2 +- sw/inc/editsh.hxx | 2 +- sw/source/core/doc/docglbl.cxx | 2 +- sw/source/core/docnode/ndsect.cxx | 27 ++++++++++++--------------- sw/source/core/edit/edsect.cxx | 2 +- sw/source/core/unocore/unosect.cxx | 3 +-- sw/source/filter/html/htmlsect.cxx | 26 ++++++++++++++------------ sw/source/filter/ww1/w1filter.cxx | 3 ++- sw/source/filter/ww8/ww8par5.cxx | 3 +-- sw/source/ui/dialog/regionsw.cxx | 2 +- sw/source/ui/dialog/uiregionsw.cxx | 5 ++--- sw/source/ui/wrtsh/wrtsh2.cxx | 2 +- 12 files changed, 38 insertions(+), 41 deletions(-) (limited to 'sw') diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index aa6992839d1f..ab19f769dc61 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -1756,7 +1756,7 @@ public: void DelSectionFmt( SwSectionFmt *pFmt, bool bDelNodes = false ); void UpdateSection(sal_uInt16 const nSect, SwSectionData &, SfxItemSet const*const = 0, bool const bPreventLinkUpdate = false); - String GetUniqueSectionName( const String* pChkStr = 0 ) const; + OUString GetUniqueSectionName( const OUString* pChkStr = 0 ) const; /* @@@MAINTAINABILITY-HORROR@@@ The model should not have anything to do with a shell. diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx index e45b4e9a54c9..4247e90bd27d 100644 --- a/sw/inc/editsh.hxx +++ b/sw/inc/editsh.hxx @@ -840,7 +840,7 @@ public: sal_Bool bChkHidden = sal_False, sal_Bool BChkTOX = sal_False ) const; - String GetUniqueSectionName( const String* pChkStr = 0 ) const; + OUString GetUniqueSectionName( const OUString* pChkStr = 0 ) const; /// Set attributes. void SetSectionAttr(const SfxItemSet& rSet, SwSectionFmt* pSectFmt = 0); diff --git a/sw/source/core/doc/docglbl.cxx b/sw/source/core/doc/docglbl.cxx index a38a4a48253d..21e26189aa15 100644 --- a/sw/source/core/doc/docglbl.cxx +++ b/sw/source/core/doc/docglbl.cxx @@ -409,7 +409,7 @@ bool SwDoc::SplitDoc( sal_uInt16 eDocType, const String& rPath, bool bOutline, c default: { - String sNm( INetURLObject( sFileName ).GetName() ); + const OUString sNm( INetURLObject( sFileName ).GetName() ); SwSectionData aSectData( FILE_LINK_SECTION, GetUniqueSectionName( &sNm )); SwSectionFmt* pFmt = MakeSectionFmt( 0 ); diff --git a/sw/source/core/docnode/ndsect.cxx b/sw/source/core/docnode/ndsect.cxx index 5aaf2d1240d6..3a643e31ad23 100644 --- a/sw/source/core/docnode/ndsect.cxx +++ b/sw/source/core/docnode/ndsect.cxx @@ -687,11 +687,11 @@ void SwDoc::UpdateSection(sal_uInt16 const nPos, SwSectionData & rNewData, && (rNewData.GetLinkFileName() != sCompareString) && (rNewData.GetLinkFileName() != pSection->GetLinkFileName())); - String sSectName( rNewData.GetSectionName() ); + OUString sSectName( rNewData.GetSectionName() ); if (sSectName != pSection->GetSectionName()) GetUniqueSectionName( &sSectName ); else - sSectName.Erase(); + sSectName = OUString(); /// In SwSection::operator=(..) class member bCondHiddenFlag is always set to sal_True. /// IMHO this have to be changed, but I can't estimate the consequences: @@ -704,7 +704,7 @@ void SwDoc::UpdateSection(sal_uInt16 const nPos, SwSectionData & rNewData, if( pAttr ) pSection->GetFmt()->SetFmtAttr( *pAttr ); - if( sSectName.Len() ) + if( !sSectName.isEmpty() ) { pSection->SetSectionName( sSectName ); } @@ -1259,9 +1259,8 @@ SwSectionNode* SwSectionNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) c } else { - const String sSectionName(GetSection().GetSectionName()); - pNewSect->SetSectionName( - pDoc->GetUniqueSectionName( &sSectionName )); + const OUString sSectionName(GetSection().GetSectionName()); + pNewSect->SetSectionName(pDoc->GetUniqueSectionName( &sSectionName )); } } @@ -1385,11 +1384,9 @@ void SwSectionNode::NodesArrChgd() } -String SwDoc::GetUniqueSectionName( const String* pChkStr ) const +OUString SwDoc::GetUniqueSectionName( const OUString* pChkStr ) const { - ResId aId( STR_REGION_DEFNAME, *pSwResMgr ); - String aName( aId ); - xub_StrLen nNmLen = aName.Len(); + const OUString aName( ResId( STR_REGION_DEFNAME, *pSwResMgr ) ); sal_uInt16 nNum = 0; sal_uInt16 nTmp, nFlagSize = ( mpSectionFmtTbl->size() / 8 ) +2; @@ -1402,15 +1399,15 @@ String SwDoc::GetUniqueSectionName( const String* pChkStr ) const for( n = 0; n < mpSectionFmtTbl->size(); ++n ) if( 0 != ( pSectNd = (*mpSectionFmtTbl)[ n ]->GetSectionNode( sal_False ) )) { - const String& rNm = pSectNd->GetSection().GetSectionName(); - if( rNm.Match( aName ) == nNmLen ) + const OUString rNm = pSectNd->GetSection().GetSectionName(); + if (rNm.startsWith( aName )) { // Calculate the Number and reset the Flag - nNum = static_cast(rNm.Copy( nNmLen ).ToInt32()); + nNum = static_cast(rNm.copy( aName.getLength() ).toInt32()); if( nNum-- && nNum < mpSectionFmtTbl->size() ) pSetFlags[ nNum / 8 ] |= (0x01 << ( nNum & 0x07 )); } - if( pChkStr && pChkStr->Equals( rNm ) ) + if( pChkStr && *pChkStr==rNm ) pChkStr = 0; } @@ -1432,7 +1429,7 @@ String SwDoc::GetUniqueSectionName( const String* pChkStr ) const delete [] pSetFlags; if( pChkStr ) return *pChkStr; - return aName += OUString::number( ++nNum ); + return aName + OUString::number( ++nNum ); } diff --git a/sw/source/core/edit/edsect.cxx b/sw/source/core/edit/edsect.cxx index abf91f9741f7..aef3213d3a08 100644 --- a/sw/source/core/edit/edsect.cxx +++ b/sw/source/core/edit/edsect.cxx @@ -169,7 +169,7 @@ void SwEditShell::UpdateSection(sal_uInt16 const nSect, EndAllAction(); } -String SwEditShell::GetUniqueSectionName( const String* pChkStr ) const +OUString SwEditShell::GetUniqueSectionName( const OUString* pChkStr ) const { return GetDoc()->GetUniqueSectionName( pChkStr ); } diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx index 1ca8cbd31296..644ba32891df 100644 --- a/sw/source/core/unocore/unosect.cxx +++ b/sw/source/core/unocore/unosect.cxx @@ -333,8 +333,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) } } - String tmp(m_pImpl->m_sName); - SwSectionData aSect(eType, pDoc->GetUniqueSectionName(&tmp)); + SwSectionData aSect(eType, pDoc->GetUniqueSectionName(&m_pImpl->m_sName)); aSect.SetCondition(m_pImpl->m_pProps->m_sCondition); OUStringBuffer sLinkNameBuf(m_pImpl->m_pProps->m_sLinkFileName); sLinkNameBuf.append(sfx2::cTokenSeparator); diff --git a/sw/source/filter/html/htmlsect.cxx b/sw/source/filter/html/htmlsect.cxx index 954606d17013..3a6eae63bbeb 100644 --- a/sw/source/filter/html/htmlsect.cxx +++ b/sw/source/filter/html/htmlsect.cxx @@ -64,7 +64,8 @@ using namespace ::com::sun::star; void SwHTMLParser::NewDivision( int nToken ) { - String aId, aHRef, aStyle, aLang, aDir; + OUString aId; + String aHRef, aStyle, aLang, aDir; OUString aClass; SvxAdjust eAdjust = HTML_CENTER_ON==nToken ? SVX_ADJUST_CENTER : SVX_ADJUST_END; @@ -113,7 +114,7 @@ void SwHTMLParser::NewDivision( int nToken ) sal_Bool bAppended = sal_False; if( pPam->GetPoint()->nContent.GetIndex() ) { - AppendTxtNode( bHeader||bFooter||aId.Len()||aHRef.Len() ? AM_NORMAL + AppendTxtNode( bHeader||bFooter||!aId.isEmpty()||aHRef.Len() ? AM_NORMAL : AM_NOSPACE ); bAppended = sal_True; } @@ -216,14 +217,14 @@ void SwHTMLParser::NewDivision( int nToken ) SwPosition aNewPos( SwNodeIndex( rCntntStIdx, 1 ), SwIndex( pCNd, 0 ) ); SaveDocContext( pCntxt, nFlags, &aNewPos ); } - else if( !bPositioned && aId.Len() > 9 && - ('s' == aId.GetChar(0) || 'S' == aId.GetChar(0) ) && - ('d' == aId.GetChar(1) || 'D' == aId.GetChar(1) ) ) + else if( !bPositioned && aId.getLength() > 9 && + (aId[0] == 's' || aId[0] == 'S' ) && + (aId[1] == 'd' || aId[1] == 'D' ) ) { sal_Bool bEndNote = sal_False, bFootNote = sal_False; - if( aId.CompareIgnoreCaseToAscii( OOO_STRING_SVTOOLS_HTML_sdendnote, 9 ) == COMPARE_EQUAL ) + if( aId.startsWithIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_sdendnote ) ) bEndNote = sal_True; - else if( aId.CompareIgnoreCaseToAscii( OOO_STRING_SVTOOLS_HTML_sdfootnote, 10 ) == COMPARE_EQUAL ) + else if( aId.startsWithIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_sdfootnote ) ) bFootNote = sal_True; if( bFootNote || bEndNote ) { @@ -235,13 +236,13 @@ void SwHTMLParser::NewDivision( int nToken ) SwNodeIndex aTmpSwNodeIndex = SwNodeIndex(*pCNd); SwPosition aNewPos( aTmpSwNodeIndex, SwIndex( pCNd, 0 ) ); SaveDocContext( pCntxt, CONTEXT_FLAGS_FTN, &aNewPos ); - aId = aPropInfo.aId = aEmptyStr; + aId = aPropInfo.aId = OUString(); } } } // Bereiche fuegen wir in Rahmen nur dann ein, wenn der Bereich gelinkt ist. - if( (aId.Len() && !bPositioned) || aHRef.Len() ) + if( (!aId.isEmpty() && !bPositioned) || aHRef.Len() ) { // Bereich einfuegen (muss vor dem Setzten von Attributen erfolgen, // weil die Section vor der PaM-Position eingefuegt. @@ -263,7 +264,7 @@ void SwHTMLParser::NewDivision( int nToken ) SetAttr( sal_True, sal_True, pPostIts ); // Namen der Section eindeutig machen - String aName( pDoc->GetUniqueSectionName( aId.Len() ? &aId : 0 ) ); + const OUString aName( pDoc->GetUniqueSectionName( !aId.isEmpty() ? &aId : 0 ) ); if( aHRef.Len() ) { @@ -541,7 +542,8 @@ sal_Bool SwHTMLParser::EndSections( sal_Bool bLFStripped ) void SwHTMLParser::NewMultiCol( sal_uInt16 columnsFromCss ) { - String aId, aStyle, aClass, aLang, aDir; + OUString aId; + String aStyle, aClass, aLang, aDir; long nWidth = 100; sal_uInt16 nCols = columnsFromCss, nGutter = 10; sal_Bool bPrcWidth = sal_True; @@ -686,7 +688,7 @@ void SwHTMLParser::NewMultiCol( sal_uInt16 columnsFromCss ) SetAttr( sal_True, sal_True, pPostIts ); // Make section name unique. - String aName( pDoc->GetUniqueSectionName( aId.Len() ? &aId : 0 ) ); + String aName( pDoc->GetUniqueSectionName( !aId.isEmpty() ? &aId : 0 ) ); SwSectionData aSection( CONTENT_SECTION, aName ); SfxItemSet aFrmItemSet( pDoc->GetAttrPool(), diff --git a/sw/source/filter/ww1/w1filter.cxx b/sw/source/filter/ww1/w1filter.cxx index 1162ae9d910e..b7f880b4f30d 100644 --- a/sw/source/filter/ww1/w1filter.cxx +++ b/sw/source/filter/ww1/w1filter.cxx @@ -838,8 +838,9 @@ oncemore: aFName = URIHelper::SmartRel2Abs( INetURLObject(rOut.GetBaseURL()), aFName ); + const OUString sStr(aStr); SwSectionData * pSection = new SwSectionData( FILE_LINK_SECTION, - rOut.GetDoc().GetUniqueSectionName( &aStr ) ); + rOut.GetDoc().GetUniqueSectionName( &sStr ) ); pSection->SetLinkFileName( aFName ); pSection->SetProtectFlag( true ); rOut << SwFltSection( pSection ); diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx index 22e1e603c624..4bee4ef1ccb5 100644 --- a/sw/source/filter/ww8/ww8par5.cxx +++ b/sw/source/filter/ww8/ww8par5.cxx @@ -2459,8 +2459,7 @@ eF_ResT SwWW8ImplReader::Read_F_IncludePicture( WW8FieldDesc*, String& rStr ) String wwSectionNamer::UniqueName() { - String aName(msFileLinkSeed); - aName += OUString::number(++mnFileSectionNo); + const OUString aName(msFileLinkSeed + OUString::number(++mnFileSectionNo)); return mrDoc.GetUniqueSectionName(&aName); } diff --git a/sw/source/ui/dialog/regionsw.cxx b/sw/source/ui/dialog/regionsw.cxx index 301c976be11c..26b9264a51ea 100644 --- a/sw/source/ui/dialog/regionsw.cxx +++ b/sw/source/ui/dialog/regionsw.cxx @@ -96,7 +96,7 @@ void SwBaseShell::InsertRegionDialog(SfxRequest& rReq) if ( SFX_ITEM_SET == pSet->GetItemState(FN_PARAM_REGION_NAME, sal_True, &pItem) ) { - String sRemoveWhenUniStringIsGone = ((const SfxStringItem *)pItem)->GetValue(); + const OUString sRemoveWhenUniStringIsGone = ((const SfxStringItem *)pItem)->GetValue(); aTmpStr = rSh.GetUniqueSectionName(&sRemoveWhenUniStringIsGone); } else diff --git a/sw/source/ui/dialog/uiregionsw.cxx b/sw/source/ui/dialog/uiregionsw.cxx index e456ee4536ac..faedf79def2f 100644 --- a/sw/source/ui/dialog/uiregionsw.cxx +++ b/sw/source/ui/dialog/uiregionsw.cxx @@ -1601,9 +1601,8 @@ void SwInsertSectionTabPage::SetWrtShell(SwWrtShell& rSh) ->GetSectionData(); if (pSectionData) // something set? { - const String sSectionName(pSectionData->GetSectionName()); - m_pCurName->SetText( - rSh.GetUniqueSectionName(&sSectionName)); + const OUString sSectionName(pSectionData->GetSectionName()); + m_pCurName->SetText(rSh.GetUniqueSectionName(&sSectionName)); m_pProtectCB->Check( 0 != pSectionData->IsProtectFlag() ); m_sFileName = pSectionData->GetLinkFileName(); m_sFilePasswd = pSectionData->GetLinkFilePassword(); diff --git a/sw/source/ui/wrtsh/wrtsh2.cxx b/sw/source/ui/wrtsh/wrtsh2.cxx index 7aae0d16e0ba..3d392df2dd8b 100644 --- a/sw/source/ui/wrtsh/wrtsh2.cxx +++ b/sw/source/ui/wrtsh/wrtsh2.cxx @@ -443,7 +443,7 @@ void SwWrtShell::NavigatorPaste( const NaviContentBookmark& rBkmk, } else { - SwSectionData aSection( FILE_LINK_SECTION, GetUniqueSectionName( 0 ) ); + SwSectionData aSection( FILE_LINK_SECTION, GetUniqueSectionName() ); String aLinkFile( rBkmk.GetURL().GetToken(0, '#') ); aLinkFile += sfx2::cTokenSeparator; aLinkFile += sfx2::cTokenSeparator; -- cgit