String to OUString

Change-Id: Ia9bebaf92bf570c10d01a9ed3db437f70098a07d
Reviewed-on: https://gerrit.libreoffice.org/5185
Reviewed-by: Luboš Luňák <l.lunak@suse.cz>
Tested-by: Luboš Luňák <l.lunak@suse.cz>
This commit is contained in:
Matteo Casalin
2013-07-26 15:37:08 +02:00
committed by Luboš Luňák
parent 9accbedad3
commit 73a136945d
12 changed files with 43 additions and 38 deletions

View File

@@ -100,7 +100,8 @@ SvXMLWordContext::SvXMLWordContext(
SvXMLImportContext ( rImport, nPrefix, rLocalName ),
rLocalRef(rImport)
{
String sRight, sWrong;
OUString sRight;
OUString sWrong;
sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
for (sal_Int16 i=0; i < nAttrCount; i++)
@@ -121,15 +122,15 @@ SvXMLWordContext::SvXMLWordContext(
}
}
}
if (!sWrong.Len() || !sRight.Len() )
if (sWrong.isEmpty() || sRight.isEmpty())
return;
sal_Bool bOnlyTxt = sRight != sWrong;
if( !bOnlyTxt )
{
String sLongSave( sRight );
const OUString sLongSave( sRight );
if( !rLocalRef.rAutoCorrect.GetLongText( rLocalRef.xStorage, String(), sWrong, sRight ) &&
sLongSave.Len() )
!sLongSave.isEmpty() )
{
sRight = sLongSave;
bOnlyTxt = sal_True;

View File

@@ -1609,14 +1609,15 @@ sal_Bool SvxAutoCorrect::MakeCombinedChanges( std::vector<SvxAutocorrWord>& aNew
// - return the replacement text (only for SWG-Format, all other
// can be taken from the word list!)
sal_Bool SvxAutoCorrect::GetLongText( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >&, const String&, const String& , String& )
sal_Bool SvxAutoCorrect::GetLongText( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >&,
const String&, const String&, OUString& )
{
return sal_False;
}
// Text with attribution (only the SWG - SWG format!)
sal_Bool SvxAutoCorrect::PutText( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >&, const String&, const String&, SfxObjectShell&,
String& )
sal_Bool SvxAutoCorrect::PutText( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >&,
const String&, const String&, SfxObjectShell&, OUString& )
{
return sal_False;
}
@@ -2541,7 +2542,7 @@ sal_Bool SvxAutoCorrectLanguageLists::PutText( const String& rShort,
MakeUserStorage_Impl();
sal_Bool bRet = sal_False;
String sLong;
OUString sLong;
try
{
uno::Reference < embed::XStorage > xStg = comphelper::OStorageHelper::GetStorageFromURL( sUserAutoCorrFile, embed::ElementModes::READWRITE );

View File

@@ -267,8 +267,8 @@ class EDITENG_DLLPUBLIC SvxAutoCorrect
protected:
// - Text with attribution (only the SWG - SWG format!)
// rShort is the stream name - encrypted!
virtual sal_Bool PutText( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& rStg, const String& rFileName, const String& rShort, SfxObjectShell& ,
String& );
virtual sal_Bool PutText( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& rStg,
const String& rFileName, const String& rShort, SfxObjectShell&, OUString& );
// required language in the table add if possible only when the file exists
sal_Bool CreateLanguageFile(LanguageType eLang, sal_Bool bNewFile = sal_True);
@@ -279,7 +279,8 @@ public:
sal_Unicode GetQuote( sal_Unicode cInsChar, sal_Bool bSttQuote,
LanguageType eLang ) const;
virtual sal_Bool GetLongText( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& rStg, const String& rFileName, const String& rShort, String& rLong );
virtual sal_Bool GetLongText( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& rStg,
const String& rFileName, const String& rShort, OUString& rLong );
TYPEINFO();

View File

@@ -31,12 +31,13 @@ class SwAutoCorrect : public SvxAutoCorrect
protected:
// Return replacement text (only for SWG-format, all others can be obtained from wordlist!).
// rShort is stream-name - encrypted!
virtual sal_Bool GetLongText( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& , const String& rFileName, const String& rShort, String& rLong );
virtual sal_Bool GetLongText( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >&,
const String& rFileName, const String& rShort, OUString& rLong );
// Text with attributes (only SWG-format!).
// rShort is stream-name - encrypted!
virtual sal_Bool PutText( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >&, const String& rFileName, const String& rShort, SfxObjectShell& ,
String& );
virtual sal_Bool PutText( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >&,
const String& rFileName, const String& rShort, SfxObjectShell&, OUString& );
public:
TYPEINFO();

View File

@@ -21,7 +21,6 @@
#define _SW_XMLBLOCKIMPORT_HXX
#include <xmloff/xmlimp.hxx>
#include <tools/string.hxx>
class SwXMLTextBlocks;
class SwXMLBlockListImport : public SvXMLImport
@@ -65,10 +64,10 @@ protected:
public:
sal_Bool bTextOnly;
String &m_rText;
OUString &m_rText;
SwXMLTextBlockImport(
const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > xContext,
SwXMLTextBlocks &rBlocks, String &rNewText, sal_Bool bNewTextOnly );
SwXMLTextBlocks &rBlocks, OUString &rNewText, sal_Bool bNewTextOnly );
SwXMLTextBlocks& getBlockList ( void )
{

View File

@@ -65,8 +65,8 @@ public:
virtual sal_uLong GetDoc( sal_uInt16 );
virtual sal_uLong BeginPutDoc( const String&, const String& );
virtual sal_uLong PutDoc();
virtual sal_uLong GetText( sal_uInt16, String& );
virtual sal_uLong PutText( const String&, const String&, const String& );
virtual sal_uLong GetText( sal_uInt16, OUString& );
virtual sal_uLong PutText( const String&, const String&, const OUString& );
virtual sal_uLong MakeBlockList();
virtual short GetFileType ( void ) const;
@@ -76,7 +76,7 @@ public:
static sal_Bool IsFileUCBStorage( const String & rFileName);
// Methods for the new Autocorrecter
sal_uLong GetText( const String& rShort, String& );
sal_uLong GetText( const String& rShort, OUString& );
virtual sal_Bool IsOnlyTextBlock( const String& rShort ) const;
virtual sal_Bool IsOnlyTextBlock( sal_uInt16 nIdx ) const;
@@ -95,7 +95,7 @@ public:
//void SetDoc( SwDoc * pNewDoc);
sal_uLong StartPutBlock( const String& rShort, const String& rPackageName );
sal_uLong PutBlock( SwPaM& rPaM, const String& rLong );
sal_uLong GetBlockText( const String& rShort, String& rText );
sal_uLong GetBlockText( const String& rShort, OUString& rText );
sal_uLong PutBlockText( const String& rShort, const String& rName, const String& rText, const String& rPackageName );
void MakeBlockText( const String& rText );

View File

@@ -60,7 +60,7 @@ class SwImpBlocks
protected:
String aFile; // physikalischer Dateiname
String aName; // logischer Name der Datei
String aCur; // aktueller Text
OUString aCur; // aktueller Text
String aShort, aLong; // Kurz- und Langname (PutDoc)
String sBaseURL; // base URL - has to be set at the Readers and Writers
SwBlockNames aNames; // Liste aller Bausteine
@@ -113,8 +113,8 @@ public:
virtual sal_uLong GetDoc( sal_uInt16 ) = 0;
virtual sal_uLong BeginPutDoc( const String&, const String& ) = 0;
virtual sal_uLong PutDoc() = 0;
virtual sal_uLong GetText( sal_uInt16, String& ) = 0;
virtual sal_uLong PutText( const String&, const String&, const String& ) = 0;
virtual sal_uLong GetText( sal_uInt16, OUString& ) = 0;
virtual sal_uLong PutText( const String&, const String&, const OUString& ) = 0;
virtual sal_uLong MakeBlockList() = 0;
virtual sal_uLong OpenFile( sal_Bool bReadOnly = sal_True ) = 0;

View File

@@ -35,7 +35,8 @@ TYPEINIT1( SwAutoCorrect, SvxAutoCorrect );
// koennen aus der Wortliste herausgeholt werden!)
// rShort ist der Stream-Name - gecryptet!
sal_Bool SwAutoCorrect::GetLongText( const uno::Reference < embed::XStorage >& rStg, const String& rFileName, const String& rShort, String& rLong )
sal_Bool SwAutoCorrect::GetLongText( const uno::Reference < embed::XStorage >& rStg,
const String& rFileName, const String& rShort, OUString& rLong )
{
sal_uLong nRet = 0;
if (rStg.is())
@@ -47,13 +48,14 @@ sal_Bool SwAutoCorrect::GetLongText( const uno::Reference < embed::XStorage >& r
else {
OSL_ENSURE( rStg.is(), "Someone passed SwAutoCorrect::GetLongText a dud storage!");
}
return !IsError( nRet ) && rLong.Len();
return !IsError( nRet ) && !rLong.isEmpty();
}
// - Text mit Attributierung (kann nur der SWG - SWG-Format!)
// rShort ist der Stream-Name - gecryptet!
sal_Bool SwAutoCorrect::PutText( const uno::Reference < embed::XStorage >& rStg, const String& rFileName, const String& rShort,
SfxObjectShell& rObjSh, String& rLong )
sal_Bool SwAutoCorrect::PutText( const uno::Reference < embed::XStorage >& rStg,
const String& rFileName, const String& rShort,
SfxObjectShell& rObjSh, OUString& rLong )
{
if( !rObjSh.IsA( TYPE(SwDocShell) ) )
return sal_False;

View File

@@ -64,7 +64,7 @@ SvXMLImportContext *SwXMLBlockListImport::CreateContext(
SwXMLTextBlockImport::SwXMLTextBlockImport(
const uno::Reference< uno::XComponentContext > xContext,
SwXMLTextBlocks &rBlocks,
String & rNewText,
OUString & rNewText,
sal_Bool bNewTextOnly )
: SvXMLImport(xContext, IMPORT_ALL ),
rBlockList ( rBlocks ),

View File

@@ -224,16 +224,16 @@ SwXMLTextBlockParContext::SwXMLTextBlockParContext(
void SwXMLTextBlockParContext::Characters( const OUString& rChars )
{
rLocalRef.m_rText.Append ( rChars.getStr());
rLocalRef.m_rText += rChars;
}
SwXMLTextBlockParContext::~SwXMLTextBlockParContext ( void )
{
if (rLocalRef.bTextOnly)
rLocalRef.m_rText.AppendAscii( "\015" );
rLocalRef.m_rText += "\015";
else
{
if (rLocalRef.m_rText.GetChar ( rLocalRef.m_rText.Len()) != ' ' )
rLocalRef.m_rText.AppendAscii( " " );
if (!rLocalRef.m_rText.endsWith( " " ))
rLocalRef.m_rText += " ";
}
}

View File

@@ -414,12 +414,12 @@ sal_uLong SwXMLTextBlocks::PutDoc()
return nErr;
}
sal_uLong SwXMLTextBlocks::GetText( sal_uInt16 nIdx, String& rText )
sal_uLong SwXMLTextBlocks::GetText( sal_uInt16 nIdx, OUString& rText )
{
return GetBlockText( aNames[ nIdx ]->aShort, rText );
}
sal_uLong SwXMLTextBlocks::GetText( const String& rShort, String& rText )
sal_uLong SwXMLTextBlocks::GetText( const String& rShort, OUString& rText )
{
return GetBlockText( rShort, rText );
}
@@ -572,7 +572,7 @@ OUString SwXMLTextBlocks::GeneratePackageName ( const String& rShort )
}
sal_uLong SwXMLTextBlocks::PutText( const String& rShort, const String& rName,
const String& rText )
const OUString& rText )
{
sal_uLong nRes = 0;
aShort = rShort;

View File

@@ -266,13 +266,13 @@ sal_uLong SwXMLTextBlocks::GetMacroTable( sal_uInt16 nIdx,
}
sal_uLong SwXMLTextBlocks::GetBlockText( const String& rShort, String& rText )
sal_uLong SwXMLTextBlocks::GetBlockText( const String& rShort, OUString& rText )
{
sal_uLong n = 0;
sal_Bool bTextOnly = sal_True;
String aFolderName = GeneratePackageName ( rShort );
String aStreamName = aFolderName + OUString(".xml");
rText.Erase();
rText = OUString();
try
{