Kaydet (Commit) 636f9032 authored tarafından Matteo Casalin's avatar Matteo Casalin Kaydeden (comit) Caolán McNamara

String to OUString

Change-Id: Ie7c04d75bcdf5b9a2b3c941b7cd8fac20a37999c
Reviewed-on: https://gerrit.libreoffice.org/5181Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst c3967de4
...@@ -49,28 +49,27 @@ using namespace ::com::sun::star; ...@@ -49,28 +49,27 @@ using namespace ::com::sun::star;
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
// PUBLIC METHODES ------------------------------------------------------- // PUBLIC METHODES -------------------------------------------------------
static String lcl_CheckFileName( const OUString& rNewFilePath, static OUString lcl_CheckFileName( const OUString& rNewFilePath,
const String& rNewGroupName ) const OUString& rNewGroupName )
{ {
String sRet; const sal_Int32 nLen = rNewGroupName.getLength();
OUStringBuffer aBuf(nLen);
//group name should contain only A-Z and a-z and spaces //group name should contain only A-Z and a-z and spaces
for( xub_StrLen i = 0; i < rNewGroupName.Len(); i++ ) for( sal_Int32 i=0; i < nLen; ++i )
{ {
sal_Unicode cChar = rNewGroupName.GetChar(i); const sal_Unicode cChar = rNewGroupName[i];
if (comphelper::string::isalnumAscii(cChar) || if (comphelper::string::isalnumAscii(cChar) ||
cChar == '_' || cChar == 0x20) cChar == '_' || cChar == 0x20)
{ {
sRet += cChar; aBuf.append(cChar);
} }
} }
sRet = comphelper::string::strip(sRet, ' ');
if( sRet.Len() ) const OUString sRet = aBuf.makeStringAndClear().trim();
if ( !sRet.isEmpty() )
{ {
String sTmpDir(rNewFilePath); const OUString sTmpDir = rNewFilePath + OUString(INET_PATH_TOKEN)
sTmpDir += INET_PATH_TOKEN; + sRet + SwGlossaries::GetExtension();
sTmpDir += sRet;
sTmpDir += SwGlossaries::GetExtension();
if (!FStatHelper::IsDocument( sTmpDir )) if (!FStatHelper::IsDocument( sTmpDir ))
return sRet; return sRet;
} }
...@@ -199,7 +198,7 @@ sal_Bool SwGlossaries::NewGroupDoc(String& rGroupName, const String& rTitle) ...@@ -199,7 +198,7 @@ sal_Bool SwGlossaries::NewGroupDoc(String& rGroupName, const String& rTitle)
sal_uInt16 nNewPath = (sal_uInt16)rGroupName.GetToken(1, GLOS_DELIM).ToInt32(); sal_uInt16 nNewPath = (sal_uInt16)rGroupName.GetToken(1, GLOS_DELIM).ToInt32();
if (static_cast<size_t>(nNewPath) >= m_PathArr.size()) if (static_cast<size_t>(nNewPath) >= m_PathArr.size())
return sal_False; return sal_False;
String sNewFilePath(m_PathArr[nNewPath]); const OUString sNewFilePath(m_PathArr[nNewPath]);
String sNewGroup = lcl_CheckFileName(sNewFilePath, rGroupName.GetToken(0, GLOS_DELIM)); String sNewGroup = lcl_CheckFileName(sNewFilePath, rGroupName.GetToken(0, GLOS_DELIM));
sNewGroup += GLOS_DELIM; sNewGroup += GLOS_DELIM;
sNewGroup += rGroupName.GetToken(1, GLOS_DELIM); sNewGroup += rGroupName.GetToken(1, GLOS_DELIM);
...@@ -222,10 +221,10 @@ sal_Bool SwGlossaries::RenameGroupDoc( ...@@ -222,10 +221,10 @@ sal_Bool SwGlossaries::RenameGroupDoc(
if (static_cast<size_t>(nOldPath) >= m_PathArr.size()) if (static_cast<size_t>(nOldPath) >= m_PathArr.size())
return sal_False; return sal_False;
String sOldFileURL(m_PathArr[nOldPath]); const OUString sOldFileURL = m_PathArr[nOldPath]
sOldFileURL += INET_PATH_TOKEN; + OUString(INET_PATH_TOKEN)
sOldFileURL += rOldGroup.GetToken(0, GLOS_DELIM); + rOldGroup.GetToken(0, GLOS_DELIM)
sOldFileURL += SwGlossaries::GetExtension(); + SwGlossaries::GetExtension();
if (!FStatHelper::IsDocument( sOldFileURL )) if (!FStatHelper::IsDocument( sOldFileURL ))
{ {
OSL_FAIL("group doesn't exist!"); OSL_FAIL("group doesn't exist!");
...@@ -236,14 +235,14 @@ sal_Bool SwGlossaries::RenameGroupDoc( ...@@ -236,14 +235,14 @@ sal_Bool SwGlossaries::RenameGroupDoc(
if (static_cast<size_t>(nNewPath) >= m_PathArr.size()) if (static_cast<size_t>(nNewPath) >= m_PathArr.size())
return sal_False; return sal_False;
String sNewFilePath(m_PathArr[nNewPath]); OUString sNewFilePath(m_PathArr[nNewPath]);
String sNewFileName = lcl_CheckFileName( OUString sNewFileName = lcl_CheckFileName(
sNewFilePath, rNewGroup.GetToken(0, GLOS_DELIM)); sNewFilePath, rNewGroup.GetToken(0, GLOS_DELIM));
const sal_uInt16 nFileNameLen = sNewFileName.Len(); const sal_Int32 nFileNameLen = sNewFileName.getLength();
sNewFileName += SwGlossaries::GetExtension(); sNewFileName += SwGlossaries::GetExtension();
String sTempNewFilePath(sNewFilePath); const OUString sTempNewFilePath = sNewFilePath
sTempNewFilePath += INET_PATH_TOKEN; + OUString(INET_PATH_TOKEN)
sTempNewFilePath += sNewFileName ; + sNewFileName;
if (FStatHelper::IsDocument( sTempNewFilePath )) if (FStatHelper::IsDocument( sTempNewFilePath ))
{ {
OSL_FAIL("group already exists!"); OSL_FAIL("group already exists!");
...@@ -255,7 +254,7 @@ sal_Bool SwGlossaries::RenameGroupDoc( ...@@ -255,7 +254,7 @@ sal_Bool SwGlossaries::RenameGroupDoc(
RemoveFileFromList( rOldGroup ); RemoveFileFromList( rOldGroup );
rNewGroup = sNewFileName.Copy(0, nFileNameLen); rNewGroup = sNewFileName.copy(0, nFileNameLen);
rNewGroup += GLOS_DELIM; rNewGroup += GLOS_DELIM;
rNewGroup += OUString::number(nNewPath); rNewGroup += OUString::number(nNewPath);
if (m_GlosArr.empty()) if (m_GlosArr.empty())
...@@ -267,8 +266,7 @@ sal_Bool SwGlossaries::RenameGroupDoc( ...@@ -267,8 +266,7 @@ sal_Bool SwGlossaries::RenameGroupDoc(
m_GlosArr.push_back(rNewGroup); m_GlosArr.push_back(rNewGroup);
} }
sNewFilePath += INET_PATH_TOKEN; sNewFilePath += OUString(INET_PATH_TOKEN) + sNewFileName;
sNewFilePath += sNewFileName ;
SwTextBlocks* pNewBlock = new SwTextBlocks( sNewFilePath ); SwTextBlocks* pNewBlock = new SwTextBlocks( sNewFilePath );
pNewBlock->SetName(rNewTitle); pNewBlock->SetName(rNewTitle);
delete pNewBlock; delete pNewBlock;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment