convert svx/source/gallery/*.cxx from String to OUString

Change-Id: I35f1f83e806ebe1bd2c81d0a85ce2a4ef4704132
This commit is contained in:
Noel Grandin
2013-09-04 14:38:18 +02:00
parent ca713640ba
commit 1287804a89
7 changed files with 77 additions and 73 deletions

View File

@@ -326,18 +326,18 @@ void GalleryBrowser1::ImplEndGalleryThemeProperties( VclAbstractDialog2* pDialog
if( nRet == RET_OK )
{
String aName( mpExchangeData->pTheme->GetName() );
OUString aName( mpExchangeData->pTheme->GetName() );
if( !mpExchangeData->aEditedTitle.isEmpty() && aName != mpExchangeData->aEditedTitle )
{
const String aOldName( aName );
String aTitle( mpExchangeData->aEditedTitle );
const OUString aOldName( aName );
OUString aTitle( mpExchangeData->aEditedTitle );
sal_uInt16 nCount = 0;
while( mpGallery->HasTheme( aTitle ) && ( nCount++ < 16000 ) )
{
aTitle = mpExchangeData->aEditedTitle;
aTitle += ' ';
aTitle += " ";
aTitle += OUString::number( nCount );
}
@@ -351,7 +351,7 @@ void GalleryBrowser1::ImplEndGalleryThemeProperties( VclAbstractDialog2* pDialog
}
}
String aThemeName( mpExchangeData->pTheme->GetName() );
OUString aThemeName( mpExchangeData->pTheme->GetName() );
mpGallery->ReleaseTheme( mpExchangeData->pTheme, *this );
if ( bCreateNew && ( nRet != RET_OK ) )
@@ -423,7 +423,7 @@ void GalleryBrowser1::ImplExecute( sal_uInt16 nId )
case( MN_RENAME ):
{
GalleryTheme* pTheme = mpGallery->AcquireTheme( GetSelectedTheme(), *this );
const String aOldName( pTheme->GetName() );
const OUString aOldName( pTheme->GetName() );
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
DBG_ASSERT(pFact, "Dialogdiet fail!");
@@ -432,17 +432,17 @@ void GalleryBrowser1::ImplExecute( sal_uInt16 nId )
if( aDlg->Execute() == RET_OK )
{
const String aNewName( aDlg->GetTitle() );
const OUString aNewName( aDlg->GetTitle() );
if( aNewName.Len() && ( aNewName != aOldName ) )
if( !aNewName.isEmpty() && ( aNewName != aOldName ) )
{
String aName( aNewName );
OUString aName( aNewName );
sal_uInt16 nCount = 0;
while( mpGallery->HasTheme( aName ) && ( nCount++ < 16000 ) )
{
aName = aNewName;
aName += ' ';
aName += " ";
aName += OUString::number( nCount );
}
@@ -690,14 +690,14 @@ IMPL_LINK_NOARG(GalleryBrowser1, SelectThemeHdl)
IMPL_LINK_NOARG(GalleryBrowser1, ClickNewThemeHdl)
{
String aNewTheme( GAL_RESSTR(RID_SVXSTR_GALLERY_NEWTHEME) );
String aName( aNewTheme );
OUString aNewTheme( GAL_RESSTR(RID_SVXSTR_GALLERY_NEWTHEME) );
OUString aName( aNewTheme );
sal_uIntPtr nCount = 0;
while( mpGallery->HasTheme( aName ) && ( nCount++ < 16000 ) )
{
aName = aNewTheme;
aName += ' ';
aName += " ";
aName += OUString::number( nCount );
}

View File

@@ -972,7 +972,7 @@ void GalleryBrowser2::ImplUpdateViews( sal_uInt16 nSelectionId )
void GalleryBrowser2::ImplUpdateInfoBar()
{
String aInfoText;
OUString aInfoText;
if( mpCurTheme )
{
@@ -1211,7 +1211,7 @@ void GalleryBrowser2::Execute( sal_uInt16 nId )
if( pObj )
{
const String aOldTitle( GetItemText( *mpCurTheme, *pObj, GALLERY_ITEM_TITLE ) );
const OUString aOldTitle( GetItemText( *mpCurTheme, *pObj, GALLERY_ITEM_TITLE ) );
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
if(pFact)
@@ -1220,12 +1220,12 @@ void GalleryBrowser2::Execute( sal_uInt16 nId )
DBG_ASSERT(aDlg, "Dialogdiet fail!");
if( aDlg->Execute() == RET_OK )
{
String aNewTitle( aDlg->GetTitle() );
OUString aNewTitle( aDlg->GetTitle() );
if( ( !aNewTitle.Len() && !pObj->GetTitle().isEmpty() ) || ( aNewTitle != aOldTitle ) )
if( ( aNewTitle.isEmpty() && !pObj->GetTitle().isEmpty() ) || ( aNewTitle != aOldTitle ) )
{
if( !aNewTitle.Len() )
aNewTitle = String( RTL_CONSTASCII_USTRINGPARAM( "__<empty>__" ) );
if( aNewTitle.isEmpty() )
aNewTitle = "__<empty>__";
pObj->SetTitle( aNewTitle );
mpCurTheme->InsertObject( *pObj );
@@ -1288,15 +1288,15 @@ OUString GalleryBrowser2::GetItemText( const GalleryTheme& rTheme, const SgaObje
if( nItemTextFlags & GALLERY_ITEM_TITLE )
{
String aTitle( rObj.GetTitle() );
OUString aTitle( rObj.GetTitle() );
if( !aTitle.Len() )
if( aTitle.isEmpty() )
aTitle = aURL.getBase( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_UNAMBIGUOUS );
if( !aTitle.Len() )
if( aTitle.isEmpty() )
{
aTitle = aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS );
aTitle = aTitle.GetToken( comphelper::string::getTokenCount(aTitle, '/') - 1, '/' );
aTitle = aTitle.getToken( comphelper::string::getTokenCount(aTitle, '/') - 1, '/' );
}
aRet += aTitle;
@@ -1304,14 +1304,14 @@ OUString GalleryBrowser2::GetItemText( const GalleryTheme& rTheme, const SgaObje
if( nItemTextFlags & GALLERY_ITEM_PATH )
{
const String aPath( aURL.getFSysPath( INetURLObject::FSYS_DETECT ) );
const OUString aPath( aURL.getFSysPath( INetURLObject::FSYS_DETECT ) );
if( aPath.Len() && ( nItemTextFlags & GALLERY_ITEM_TITLE ) )
aRet += String( RTL_CONSTASCII_USTRINGPARAM( " (" ) );
if( !aPath.isEmpty() && ( nItemTextFlags & GALLERY_ITEM_TITLE ) )
aRet += " (";
aRet += String(aURL.getFSysPath( INetURLObject::FSYS_DETECT ));
aRet += aURL.getFSysPath( INetURLObject::FSYS_DETECT );
if( aPath.Len() && ( nItemTextFlags & GALLERY_ITEM_TITLE ) )
if( !aPath.isEmpty() && ( nItemTextFlags & GALLERY_ITEM_TITLE ) )
aRet += ")";
}

View File

@@ -239,7 +239,7 @@ void Gallery::ImplLoadSubDirs( const INetURLObject& rBaseURL, sal_Bool& rbDirIsR
{
// check readonlyness the very hard way
INetURLObject aTestURL( rBaseURL );
String aTestFile( RTL_CONSTASCII_USTRINGPARAM( "cdefghij.klm" ) );
OUString aTestFile( "cdefghij.klm" );
aTestURL.Append( aTestFile );
SvStream* pTestStm = ::utl::UcbStreamHelper::CreateStream( aTestURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_WRITE );
@@ -547,7 +547,7 @@ sal_Bool Gallery::RenameTheme( const OUString& rOldName, const OUString& rNewNam
if( pThm )
{
const String aOldName( rOldName );
const OUString aOldName( rOldName );
pThemeEntry->SetName( rNewName );
pThm->ImplWrite();

View File

@@ -247,12 +247,12 @@ OUString GetReducedString( const INetURLObject& rURL, sal_Int32 nMaxLen )
String GetSvDrawStreamNameFromURL( const INetURLObject& rSvDrawObjURL )
{
String aRet;
OUString aRet;
if( rSvDrawObjURL.GetProtocol() == INET_PROT_PRIV_SOFFICE &&
comphelper::string::getTokenCount(rSvDrawObjURL.GetMainURL( INetURLObject::NO_DECODE ), '/') == 3 )
{
aRet = String(rSvDrawObjURL.GetMainURL( INetURLObject::NO_DECODE )).GetToken( 2, '/' );
aRet = rSvDrawObjURL.GetMainURL( INetURLObject::NO_DECODE ).getToken( 2, '/' );
}
return aRet;
@@ -405,7 +405,7 @@ GalleryProgress::GalleryProgress( GraphicFilter* pFilter ) :
if( mxProgressBar.is() )
{
String aProgressText;
OUString aProgressText;
if( mpFilter )
{
@@ -415,9 +415,9 @@ GalleryProgress::GalleryProgress( GraphicFilter* pFilter ) :
// // be changed to use the XStatusIndicator instead of XProgressMonitor
}
else
aProgressText = String( RTL_CONSTASCII_USTRINGPARAM( "Gallery" ) );
aProgressText = "Gallery";
xMonitor->addText( String( RTL_CONSTASCII_USTRINGPARAM( "Gallery" ) ), aProgressText, sal_False ) ;
xMonitor->addText( "Gallery", aProgressText, sal_False ) ;
mxProgressBar->setRange( 0, GALLERY_PROGRESS_RANGE );
}
}
@@ -483,7 +483,7 @@ void GalleryTransferable::InitData( bool bLazy )
if( !mxModelStream.Is() )
{
mxModelStream = new SotStorageStream( String() );
mxModelStream = new SotStorageStream( "" );
mxModelStream->SetBufferSize( 16348 );
if( !mpTheme->GetModelStream( mnObjectPos, mxModelStream ) )

View File

@@ -198,8 +198,8 @@ void SgaObject::WriteData( SvStream& rOut, const OUString& rDestDir ) const
else
rOut << aThumbMtf;
String aURLWithoutDestDir = String(aURL.GetMainURL( INetURLObject::NO_DECODE ));
aURLWithoutDestDir.SearchAndReplace(rDestDir, String());
OUString aURLWithoutDestDir = aURL.GetMainURL( INetURLObject::NO_DECODE );
aURLWithoutDestDir = aURLWithoutDestDir.replaceFirst(rDestDir, "");
write_lenPrefixed_uInt8s_FromOUString<sal_uInt16>(rOut, aURLWithoutDestDir, RTL_TEXTENCODING_UTF8);
}
@@ -234,11 +234,11 @@ const OUString SgaObject::GetTitle() const
{
if ( comphelper::string::getTokenCount(aReturnValue, ':') == 3 )
{
String aPrivateInd ( aReturnValue.getToken( 0, ':' ) );
String aResourceName( aReturnValue.getToken( 1, ':' ) );
OUString aPrivateInd ( aReturnValue.getToken( 0, ':' ) );
OUString aResourceName( aReturnValue.getToken( 1, ':' ) );
sal_Int32 nResId ( aReturnValue.getToken( 2, ':' ).toInt32() );
if ( aPrivateInd.EqualsAscii( "private" ) &&
aResourceName.Len() && ( nResId > 0 ) && ( nResId < 0x10000 ) )
if ( aPrivateInd == "private" &&
!aResourceName.isEmpty() && ( nResId > 0 ) && ( nResId < 0x10000 ) )
{
OString aMgrName(OUStringToOString(aResourceName, RTL_TEXTENCODING_UTF8));
ResMgr* pResMgr = ResMgr::CreateResMgr( aMgrName.getStr(),
@@ -270,7 +270,7 @@ void SgaObject::SetTitle( const OUString& rTitle )
SvStream& operator<<( SvStream& rOut, const SgaObject& rObj )
{
rObj.WriteData( rOut, String() );
rObj.WriteData( rOut, "" );
return rOut;
}
@@ -491,7 +491,7 @@ SvxGalleryDrawModel::SvxGalleryDrawModel()
{
DBG_CTOR(SvxGalleryDrawModel,NULL);
const String sFactoryURL(RTL_CONSTASCII_USTRINGPARAM("sdraw"));
const OUString sFactoryURL("sdraw");
mxDoc = SfxObjectShell::CreateObjectByFactoryName( sFactoryURL );

View File

@@ -262,10 +262,10 @@ INetURLObject GalleryTheme::ImplCreateUniqueURL( SgaObjKind eObjKind, sal_uIntPt
sal_Char const* pExt = NULL;
sal_Bool bExists;
aDir.Append( String( RTL_CONSTASCII_USTRINGPARAM( "dragdrop" ) ) );
aDir.Append( OUString("dragdrop") );
CreateDir( aDir );
aInfoFileURL.Append( String( RTL_CONSTASCII_USTRINGPARAM( "sdddndx1" ) ) );
aInfoFileURL.Append( OUString("sdddndx1") );
// read next possible number
if( FileExists( aInfoFileURL ) )
@@ -306,7 +306,7 @@ INetURLObject GalleryTheme::ImplCreateUniqueURL( SgaObjKind eObjKind, sal_uIntPt
// get URL
if( SGA_OBJ_SVDRAW == eObjKind )
{
String aFileName( RTL_CONSTASCII_USTRINGPARAM( "gallery/svdraw/dd" ) );
OUString aFileName( "gallery/svdraw/dd" );
aNewURL = INetURLObject( aFileName += OUString::number( ++nNextNumber % 99999999 ), INET_PROT_PRIV_SOFFICE );
bExists = sal_False;
@@ -320,10 +320,10 @@ INetURLObject GalleryTheme::ImplCreateUniqueURL( SgaObjKind eObjKind, sal_uIntPt
}
else
{
String aFileName( RTL_CONSTASCII_USTRINGPARAM( "dd" ) );
OUString aFileName( "dd" );
aFileName += OUString::number( ++nNextNumber % 999999 );
aFileName += String( pExt, RTL_TEXTENCODING_ASCII_US );
aFileName += OUString( pExt, strlen(pExt), RTL_TEXTENCODING_ASCII_US );
aNewURL = aDir;
aNewURL.Append( aFileName );
@@ -617,7 +617,7 @@ void GalleryTheme::Actualize( const Link& rActualizeLink, GalleryProgress* pProg
{
if ( aSvDrawStorageRef.Is() )
{
const String aStmName( GetSvDrawStreamNameFromURL( pEntry->aURL ) );
const OUString aStmName( GetSvDrawStreamNameFromURL( pEntry->aURL ) );
SvStorageStreamRef pIStm = aSvDrawStorageRef->OpenSotStream( aStmName, STREAM_READ );
if( pIStm && !pIStm->GetError() )
@@ -739,7 +739,7 @@ GalleryThemeEntry* GalleryTheme::CreateThemeEntry( const INetURLObject& rURL, sa
if( pIStm )
{
String aThemeName;
OUString aThemeName;
sal_uInt16 nVersion;
sal_Bool bThemeNameFromResource = sal_False;
@@ -986,7 +986,7 @@ sal_Bool GalleryTheme::GetModel( sal_uIntPtr nPos, SdrModel& rModel, sal_Bool )
if( xStor.Is() )
{
const String aStmName( GetSvDrawStreamNameFromURL( aURL ) );
const OUString aStmName( GetSvDrawStreamNameFromURL( aURL ) );
SvStorageStreamRef xIStm( xStor->OpenSotStream( aStmName, STREAM_READ ) );
if( xIStm.Is() && !xIStm->GetError() )
@@ -1011,7 +1011,7 @@ sal_Bool GalleryTheme::InsertModel( const FmFormModel& rModel, sal_uIntPtr nInse
if( xStor.Is() )
{
const String aStmName( GetSvDrawStreamNameFromURL( aURL ) );
const OUString aStmName( GetSvDrawStreamNameFromURL( aURL ) );
SvStorageStreamRef xOStm( xStor->OpenSotStream( aStmName, STREAM_WRITE | STREAM_TRUNC ) );
if( xOStm.Is() && !xOStm->GetError() )
@@ -1062,7 +1062,7 @@ sal_Bool GalleryTheme::GetModelStream( sal_uIntPtr nPos, SotStorageStreamRef& rx
if( xStor.Is() )
{
const String aStmName( GetSvDrawStreamNameFromURL( aURL ) );
const OUString aStmName( GetSvDrawStreamNameFromURL( aURL ) );
SvStorageStreamRef xIStm( xStor->OpenSotStream( aStmName, STREAM_READ ) );
if( xIStm.Is() && !xIStm->GetError() )
@@ -1111,7 +1111,7 @@ sal_Bool GalleryTheme::InsertModelStream( const SotStorageStreamRef& rxModelStre
if( xStor.Is() )
{
const String aStmName( GetSvDrawStreamNameFromURL( aURL ) );
const OUString aStmName( GetSvDrawStreamNameFromURL( aURL ) );
SvStorageStreamRef xOStm( xStor->OpenSotStream( aStmName, STREAM_WRITE | STREAM_TRUNC ) );
if( xOStm.Is() && !xOStm->GetError() )
@@ -1271,7 +1271,7 @@ sal_Bool GalleryTheme::InsertTransferable( const uno::Reference< datatransfer::X
for( sal_uInt32 i = 0, nCount = aFileList.Count(); i < nCount; ++i )
{
const String aFile( aFileList.GetFile( i ) );
const OUString aFile( aFileList.GetFile( i ) );
INetURLObject aURL( aFile );
if( aURL.GetProtocol() == INET_PROT_NOT_VALID )
@@ -1373,7 +1373,7 @@ SvStream& GalleryTheme::WriteData( SvStream& rOStm ) const
for( sal_uInt32 i = 0; i < nCount; i++ )
{
const GalleryObject* pObj = ImplGetGalleryObject( i );
String aPath;
OUString aPath;
if( SGA_OBJ_SVDRAW == pObj->eObjKind )
{
@@ -1383,22 +1383,24 @@ SvStream& GalleryTheme::WriteData( SvStream& rOStm ) const
else
{
aPath = pObj->aURL.GetMainURL( INetURLObject::NO_DECODE );
bRel = ( ( aPath.Erase( sal::static_int_cast< xub_StrLen >( aRelURL1.GetMainURL( INetURLObject::NO_DECODE ).getLength() ) ) ) == String(aRelURL1.GetMainURL( INetURLObject::NO_DECODE ) ));
aPath = aPath.copy( 0, aRelURL1.GetMainURL( INetURLObject::NO_DECODE ).getLength() );
bRel = aPath == aRelURL1.GetMainURL( INetURLObject::NO_DECODE );
if( bRel && ( pObj->aURL.GetMainURL( INetURLObject::NO_DECODE ).getLength() > ( aRelURL1.GetMainURL( INetURLObject::NO_DECODE ).getLength() + 1 ) ) )
{
aPath = pObj->aURL.GetMainURL( INetURLObject::NO_DECODE );
aPath = aPath.Erase( 0, sal::static_int_cast< xub_StrLen >( aRelURL1.GetMainURL( INetURLObject::NO_DECODE ).getLength() ) );
aPath = aPath.copy( aRelURL1.GetMainURL( INetURLObject::NO_DECODE ).getLength() );
}
else
{
aPath = pObj->aURL.GetMainURL( INetURLObject::NO_DECODE );
bRel = ( ( aPath.Erase( sal::static_int_cast< xub_StrLen >( aRelURL2.GetMainURL( INetURLObject::NO_DECODE ).getLength() ) ) ) == String(aRelURL2.GetMainURL( INetURLObject::NO_DECODE ) ));
aPath = aPath.copy( 0, aRelURL2.GetMainURL( INetURLObject::NO_DECODE ).getLength() );
bRel = aPath == aRelURL2.GetMainURL( INetURLObject::NO_DECODE );
if( bRel && ( pObj->aURL.GetMainURL( INetURLObject::NO_DECODE ).getLength() > ( aRelURL2.GetMainURL( INetURLObject::NO_DECODE ).getLength() + 1 ) ) )
{
aPath = pObj->aURL.GetMainURL( INetURLObject::NO_DECODE );
aPath = aPath.Erase( 0, sal::static_int_cast< xub_StrLen >( aRelURL2.GetMainURL( INetURLObject::NO_DECODE ).getLength() ) );
aPath = aPath.copy( aRelURL2.GetMainURL( INetURLObject::NO_DECODE ).getLength() );
}
else
aPath = pObj->aURL.GetMainURL( INetURLObject::NO_DECODE );
@@ -1407,7 +1409,9 @@ SvStream& GalleryTheme::WriteData( SvStream& rOStm ) const
if ( !m_aDestDir.isEmpty() )
{
if ( aPath.SearchAndReplace(m_aDestDir, String()) != STRING_NOTFOUND )
bool aFound = aPath.indexOf(m_aDestDir) != -1;
aPath = aPath.replaceFirst(m_aDestDir, "");
if ( aFound )
bRel = m_bDestDirRelative;
else
SAL_WARN( "svx", "failed to replace destdir of '"
@@ -1450,7 +1454,7 @@ SvStream& GalleryTheme::ReadData( SvStream& rIStm )
{
sal_uInt32 nCount;
sal_uInt16 nVersion;
String aThemeName;
OUString aThemeName;
rtl_TextEncoding nTextEncoding;
rIStm >> nVersion;
@@ -1489,8 +1493,8 @@ SvStream& GalleryTheme::ReadData( SvStream& rIStm )
{
pObj = new GalleryObject;
String aFileName;
String aPath;
OUString aFileName;
OUString aPath;
sal_uInt16 nTemp;
rIStm >> bRel;
@@ -1502,11 +1506,11 @@ SvStream& GalleryTheme::ReadData( SvStream& rIStm )
if( bRel )
{
aFileName.SearchAndReplaceAll( '\\', '/' );
aFileName = aFileName.replaceAll( "\\", "/" );
aPath = aRelURL1.GetMainURL( INetURLObject::NO_DECODE );
if( aFileName.GetChar( 0 ) != '/' )
aPath += '/';
if( aFileName[ 0 ] != '/' )
aPath += "/";
aPath += aFileName;
@@ -1516,8 +1520,8 @@ SvStream& GalleryTheme::ReadData( SvStream& rIStm )
{
aPath = aRelURL2.GetMainURL( INetURLObject::NO_DECODE );
if( aFileName.GetChar( 0 ) != '/' )
aPath += '/';
if( aFileName[0] != '/' )
aPath += "/";
aPath += aFileName;
@@ -1529,9 +1533,9 @@ SvStream& GalleryTheme::ReadData( SvStream& rIStm )
{
if( SGA_OBJ_SVDRAW == pObj->eObjKind )
{
const static String aBaseURLStr( RTL_CONSTASCII_USTRINGPARAM( "gallery/svdraw/" ) );
const static OUString aBaseURLStr( "gallery/svdraw/" );
String aDummyURL( aBaseURLStr );
OUString aDummyURL( aBaseURLStr );
pObj->aURL = INetURLObject( aDummyURL += aFileName, INET_PROT_PRIV_SOFFICE );
}
else

View File

@@ -109,7 +109,7 @@ static void createTheme( OUString aThemeName, OUString aGalleryURL,
fprintf( stderr, "Using DestDir: %s\n",
OUStringToOString( aDestDir, RTL_TEXTENCODING_UTF8 ).getStr() );
pGalTheme->SetDestDir( String( aDestDir ), bRelativeURLs );
pGalTheme->SetDestDir( aDestDir, bRelativeURLs );
FileNameList::const_iterator aIter;