summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatteo Casalin <matteo.casalin@yahoo.com>2013-08-19 23:17:40 +0200
committerMichael Stahl <mstahl@redhat.com>2013-08-21 10:15:22 +0000
commitc35f100bbbcf9aef83b7a68d625aa8d083c02b7d (patch)
tree4f550840652fc07146e729ce1636c0cbdd4efa6c
parentd71f56e413caf6616688d76a020b4ef4804c7714 (diff)
String to OUString
Change-Id: I3161b18f73fd3141b9832e0277d3f1071f75ba39 Reviewed-on: https://gerrit.libreoffice.org/5560 Reviewed-by: Michael Stahl <mstahl@redhat.com> Tested-by: Michael Stahl <mstahl@redhat.com>
-rw-r--r--sw/inc/doc.hxx4
-rw-r--r--sw/inc/editsh.hxx2
-rw-r--r--sw/source/core/doc/docnum.cxx31
-rw-r--r--sw/source/core/edit/ednumber.cxx2
-rw-r--r--sw/source/filter/ww8/wrtw8num.cxx3
-rw-r--r--sw/source/filter/ww8/ww8par2.cxx6
-rw-r--r--sw/source/filter/ww8/ww8par3.cxx6
-rw-r--r--sw/source/ui/app/docstyle.cxx5
-rw-r--r--sw/source/ui/shells/txtnum.cxx6
9 files changed, 29 insertions, 36 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 7e0dae64b355..24a4216d324d 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -1513,7 +1513,7 @@ public:
void AddNumRule(SwNumRule * pRule);
/// add optional parameter <eDefaultNumberFormatPositionAndSpaceMode>
- sal_uInt16 MakeNumRule( const String &rName,
+ sal_uInt16 MakeNumRule( const OUString &rName,
const SwNumRule* pCpy = 0,
bool bBroadcast = false,
const SvxNumberFormat::SvxNumPositionAndSpaceMode eDefaultNumberFormatPositionAndSpaceMode =
@@ -1525,7 +1525,7 @@ public:
bool RenameNumRule(const String & aOldName, const String & aNewName,
bool bBroadcast = false);
bool DelNumRule( const String& rName, bool bBroadCast = false );
- String GetUniqueNumRuleName( const String* pChkStr = 0, bool bAutoNum = true ) const;
+ OUString GetUniqueNumRuleName( const OUString* pChkStr = 0, bool bAutoNum = true ) const;
void UpdateNumRule(); /// Update all invalids.
void ChgNumRuleFmts( const SwNumRule& rRule, const String * pOldName = 0 );
diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index 86ed749f72e1..08c71c39f762 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -526,7 +526,7 @@ public:
sal_Bool SelectionHasNumber() const;
sal_Bool SelectionHasBullet() const;
- String GetUniqueNumRuleName( const String* pChkStr = 0, bool bAutoNum = true ) const;
+ OUString GetUniqueNumRuleName( const OUString* pChkStr = 0, bool bAutoNum = true ) const;
void ChgNumRuleFmts( const SwNumRule& rRule );
/// Set (and query if) a numbering with StartFlag starts at current PointPos.
diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx
index 04e0e4504fb7..a7872ace8f08 100644
--- a/sw/source/core/doc/docnum.cxx
+++ b/sw/source/core/doc/docnum.cxx
@@ -2165,7 +2165,7 @@ void SwDoc::AddNumRule(SwNumRule * pRule)
createListForListStyle( pRule->GetName() );
}
-sal_uInt16 SwDoc::MakeNumRule( const String &rName,
+sal_uInt16 SwDoc::MakeNumRule( const OUString &rName,
const SwNumRule* pCpy,
bool bBroadcast,
const SvxNumberFormat::SvxNumPositionAndSpaceMode eDefaultNumberFormatPositionAndSpaceMode )
@@ -2209,19 +2209,19 @@ sal_uInt16 SwDoc::MakeNumRule( const String &rName,
return nRet;
}
-String SwDoc::GetUniqueNumRuleName( const String* pChkStr, bool bAutoNum ) const
+OUString SwDoc::GetUniqueNumRuleName( const OUString* pChkStr, bool bAutoNum ) const
{
- String aName;
+ OUString aName;
if( bAutoNum )
{
static rtlRandomPool s_RandomPool( rtl_random_createPool() );
sal_Int64 n;
rtl_random_getBytes( s_RandomPool, &n, sizeof(n) );
aName = OUString::valueOf( (n < 0 ? -n : n) );
- if( pChkStr && !pChkStr->Len() )
+ if( pChkStr && pChkStr->isEmpty() )
pChkStr = 0;
}
- else if( pChkStr && pChkStr->Len() )
+ else if( pChkStr && !pChkStr->isEmpty() )
aName = *pChkStr;
else
{
@@ -2233,16 +2233,15 @@ String SwDoc::GetUniqueNumRuleName( const String* pChkStr, bool bAutoNum ) const
sal_uInt8* pSetFlags = new sal_uInt8[ nFlagSize ];
memset( pSetFlags, 0, nFlagSize );
- xub_StrLen nNmLen = aName.Len();
+ sal_Int32 nNmLen = aName.getLength();
if( !bAutoNum && pChkStr )
{
- while( nNmLen-- && '0' <= aName.GetChar( nNmLen ) &&
- '9' >= aName.GetChar( nNmLen ) )
+ while( nNmLen-- && '0' <= aName[nNmLen] && aName[nNmLen] <= '9' )
; //nop
- if( ++nNmLen < aName.Len() )
+ if( ++nNmLen < aName.getLength() )
{
- aName.Erase( nNmLen );
+ aName = aName.copy(0, nNmLen );
pChkStr = 0;
}
}
@@ -2253,15 +2252,15 @@ String SwDoc::GetUniqueNumRuleName( const String* pChkStr, bool bAutoNum ) const
for( n = 0; n < mpNumRuleTbl->size(); ++n )
if( 0 != ( pNumRule = (*mpNumRuleTbl)[ n ] ) )
{
- const String& rNm = pNumRule->GetName();
- if( rNm.Match( aName ) == nNmLen )
+ const OUString sNm = pNumRule->GetName();
+ if( sNm.startsWith( aName ) )
{
// Determine Number and set the Flag
- nNum = (sal_uInt16)rNm.Copy( nNmLen ).ToInt32();
+ nNum = (sal_uInt16)sNm.copy( nNmLen ).toInt32();
if( nNum-- && nNum < mpNumRuleTbl->size() )
pSetFlags[ nNum / 8 ] |= (0x01 << ( nNum & 0x07 ));
}
- if( pChkStr && pChkStr->Equals( rNm ) )
+ if( pChkStr && *pChkStr==sNm )
pChkStr = 0;
}
@@ -2281,9 +2280,9 @@ String SwDoc::GetUniqueNumRuleName( const String* pChkStr, bool bAutoNum ) const
}
delete [] pSetFlags;
- if( pChkStr && pChkStr->Len() )
+ if( pChkStr && !pChkStr->isEmpty() )
return *pChkStr;
- return aName += OUString::number( ++nNum );
+ return aName + OUString::number( ++nNum );
}
void SwDoc::UpdateNumRule()
diff --git a/sw/source/core/edit/ednumber.cxx b/sw/source/core/edit/ednumber.cxx
index 5d3afe013385..282ed26928c5 100644
--- a/sw/source/core/edit/ednumber.cxx
+++ b/sw/source/core/edit/ednumber.cxx
@@ -743,7 +743,7 @@ void SwEditShell::SetCurNumRule( const SwNumRule& rRule,
EndAllAction();
}
-String SwEditShell::GetUniqueNumRuleName( const String* pChkStr, bool bAutoNum ) const
+OUString SwEditShell::GetUniqueNumRuleName( const OUString* pChkStr, bool bAutoNum ) const
{
return GetDoc()->GetUniqueNumRuleName( pChkStr, bAutoNum );
}
diff --git a/sw/source/filter/ww8/wrtw8num.cxx b/sw/source/filter/ww8/wrtw8num.cxx
index ed469f72bb88..f0caf1917a58 100644
--- a/sw/source/filter/ww8/wrtw8num.cxx
+++ b/sw/source/filter/ww8/wrtw8num.cxx
@@ -46,8 +46,7 @@ using namespace sw::util;
sal_uInt16 MSWordExportBase::DuplicateNumRule( const SwNumRule *pRule, sal_uInt8 nLevel, sal_uInt16 nVal )
{
sal_uInt16 nNumId = USHRT_MAX;
- String sPrefix(OUString("WW8TempExport"));
- sPrefix += OUString::number( nUniqueList++ );
+ const OUString sPrefix("WW8TempExport" + OUString::number( nUniqueList++ ));
SwNumRule* pMyNumRule =
new SwNumRule( pDoc->GetUniqueNumRuleName( &sPrefix ),
SvxNumberFormat::LABEL_WIDTH_AND_POSITION );
diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index c8241826e313..7fe428f5a399 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -716,8 +716,8 @@ SwNumRule* SwWW8ImplReader::GetStyRule()
if( pStyles->pStyRule ) // Bullet-Style already present
return pStyles->pStyRule;
- const String aBaseName(OUString("WW8StyleNum"));
- const String aName( rDoc.GetUniqueNumRuleName( &aBaseName, false) );
+ const OUString aBaseName("WW8StyleNum");
+ const OUString aName( rDoc.GetUniqueNumRuleName( &aBaseName, false) );
// #i86652#
sal_uInt16 nRul = rDoc.MakeNumRule( aName, 0, false,
@@ -792,7 +792,7 @@ void SwWW8ImplReader::Read_ANLevelDesc( sal_uInt16, const sal_uInt8* pData, shor
// If NumRuleItems were set, either directly or through inheritance, disable them now
pAktColl->SetFmtAttr( SwNumRuleItem() );
- String aName(OUString("Outline"));
+ const OUString aName("Outline");
SwNumRule aNR( rDoc.GetUniqueNumRuleName( &aName ),
SvxNumberFormat::LABEL_WIDTH_AND_POSITION,
OUTLINE_RULE );
diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx
index e00b6d27ea3b..9086aed3dbec 100644
--- a/sw/source/filter/ww8/ww8par3.cxx
+++ b/sw/source/filter/ww8/ww8par3.cxx
@@ -1079,8 +1079,7 @@ void WW8ListManager::AdjustLVL( sal_uInt8 nLevel, SwNumRule& rNumRule,
SwNumRule* WW8ListManager::CreateNextRule(bool bSimple)
{
// wird erstmal zur Bildung des Style Namens genommen
- String sPrefix(OUString("WW8Num"));
- sPrefix += OUString::number(nUniqueList++);
+ const OUString sPrefix("WW8Num" + OUString::number(nUniqueList++));
// #i86652#
sal_uInt16 nRul =
rDoc.MakeNumRule( rDoc.GetUniqueNumRuleName(&sPrefix), 0, false,
@@ -1322,8 +1321,7 @@ WW8ListManager::WW8ListManager(SvStream& rSt_, SwWW8ImplReader& rReader_)
break;
// Nauemsprefix aufbauen: fuer NumRule-Name (eventuell)
// und (falls vorhanden) fuer Style-Name (dann auf jeden Fall)
- String sPrefix(OUString("WW8NumSt"));
- sPrefix += OUString::number( nLfo + 1 );
+ const OUString sPrefix("WW8NumSt" + OUString::number( nLfo + 1 ));
// jetzt dem pNumRule seinen RICHTIGEN Wert zuweisen !!!
// (bis dahin war hier die Parent NumRule vermerkt )
//
diff --git a/sw/source/ui/app/docstyle.cxx b/sw/source/ui/app/docstyle.cxx
index 848ac7fa8a64..901ca80484e9 100644
--- a/sw/source/ui/app/docstyle.cxx
+++ b/sw/source/ui/app/docstyle.cxx
@@ -1780,10 +1780,7 @@ void SwDocStyleSheet::Create()
pNumRule = lcl_FindNumRule( rDoc, aName );
if( !pNumRule )
{
- OUString sTmpNm( aName );
- if( aName.isEmpty() )
- sTmpNm = rDoc.GetUniqueNumRuleName();
-
+ const OUString sTmpNm( aName.isEmpty() ? rDoc.GetUniqueNumRuleName() : aName );
SwNumRule* pRule = rDoc.GetNumRuleTbl()[
rDoc.MakeNumRule( sTmpNm, 0, false,
// #i89178#
diff --git a/sw/source/ui/shells/txtnum.cxx b/sw/source/ui/shells/txtnum.cxx
index f55e3f22fdaf..62e36f07fb7e 100644
--- a/sw/source/ui/shells/txtnum.cxx
+++ b/sw/source/ui/shells/txtnum.cxx
@@ -201,7 +201,7 @@ void SwTextShell::ExecEnterNum(SfxRequest &rReq)
pSetRule->UnLinkGraphics();
SwNumRule aSetRule( pCurRule
? pCurRule->GetName()
- : GetShell().GetUniqueNumRuleName(),
+ : String(GetShell().GetUniqueNumRuleName()),
// #i89178#
numfunc::GetDefaultPositionAndSpaceMode() );
aSetRule.SetSvxRule( *pSetRule, GetShell().GetDoc());
@@ -343,7 +343,7 @@ void SwTextShell::ExecSetNumber(SfxRequest &rReq)
aSvxRule.UnLinkGraphics();
SwNumRule aSetRule( pCurRule
? pCurRule->GetName()
- : GetShell().GetUniqueNumRuleName(),
+ : String(GetShell().GetUniqueNumRuleName()),
numfunc::GetDefaultPositionAndSpaceMode() );
aSetRule.SetSvxRule( aSvxRule, GetShell().GetDoc());
@@ -397,7 +397,7 @@ void SwTextShell::ExecSetNumber(SfxRequest &rReq)
SwNumRule aSetRule( pCurRule
? pCurRule->GetName()
- : GetShell().GetUniqueNumRuleName(),
+ : String(GetShell().GetUniqueNumRuleName()),
numfunc::GetDefaultPositionAndSpaceMode() );
aSetRule.SetSvxRule( aSvxRule, GetShell().GetDoc());