diff options
author | Norbert Thiebaud <nthiebaud@gmail.com> | 2012-11-25 00:33:44 -0600 |
---|---|---|
committer | Norbert Thiebaud <nthiebaud@gmail.com> | 2012-11-27 22:59:29 -0600 |
commit | 1a8ac8b2df40edd0b17825e2ca0cb170061d0ff1 (patch) | |
tree | ed2f435b817f5dcfc7e5df588966de3337f78ea0 /xmloff/source/style | |
parent | 739146b75d8f3e537759925ba6e17cddd28e1acf (diff) |
String and OUString cleaning in xmloff
Change-Id: I85d7fd7733814c60a048a7f87d43fbcbb83b0eb0
Diffstat (limited to 'xmloff/source/style')
-rw-r--r-- | xmloff/source/style/styleexp.cxx | 20 | ||||
-rw-r--r-- | xmloff/source/style/xmlnumfe.cxx | 4 | ||||
-rw-r--r-- | xmloff/source/style/xmlnumfi.cxx | 98 | ||||
-rw-r--r-- | xmloff/source/style/xmlnumi.cxx | 9 | ||||
-rw-r--r-- | xmloff/source/style/xmlstyle.cxx | 44 |
5 files changed, 81 insertions, 94 deletions
diff --git a/xmloff/source/style/styleexp.cxx b/xmloff/source/style/styleexp.cxx index ef20a9796a7d..2970392078fa 100644 --- a/xmloff/source/style/styleexp.cxx +++ b/xmloff/source/style/styleexp.cxx @@ -18,7 +18,6 @@ */ #include <tools/debug.hxx> -#include <tools/string.hxx> #include <xmloff/nmspmap.hxx> #include "xmloff/xmlnmspe.hxx" #include <xmloff/xmltoken.hxx> @@ -42,9 +41,6 @@ #include <set> #include <boost/scoped_ptr.hpp> -using ::rtl::OUString; -using ::rtl::OUStringBuffer; - using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::style; @@ -57,7 +53,7 @@ using ::com::sun::star::document::XEventsSupplier; XMLStyleExport::XMLStyleExport( SvXMLExport& rExp, - const ::rtl::OUString& rPoolStyleName, + const OUString& rPoolStyleName, SvXMLAutoStylePoolP *pAutoStyleP ) : rExport( rExp ), sIsPhysical( RTL_CONSTASCII_USTRINGPARAM( "IsPhysical" ) ), @@ -84,7 +80,7 @@ void XMLStyleExport::exportStyleContent( const Reference< XStyle >& ) sal_Bool XMLStyleExport::exportStyle( const Reference< XStyle >& rStyle, - const OUString& rXMLFamily, + const OUString& rXMLFamily, const UniReference < SvXMLExportPropertyMapper >& rPropMapper, const Reference< XNameAccess >& xStyles, const OUString* pPrefix ) @@ -396,12 +392,12 @@ void XMLStyleExport::exportStyleFamily( // If next styles are supported and used styles should be exported only, // the next style may be unused but has to be exported, too. In this case // the names of all exported styles are remembered. - boost::scoped_ptr<std::set<String> > pExportedStyles(0); + boost::scoped_ptr<std::set<OUString> > pExportedStyles(0); sal_Bool bFirstStyle = sal_True; - const uno::Sequence< ::rtl::OUString> aSeq = xStyles->getElementNames(); - const ::rtl::OUString* pIter = aSeq.getConstArray(); - const ::rtl::OUString* pEnd = pIter + aSeq.getLength(); + const uno::Sequence< OUString> aSeq = xStyles->getElementNames(); + const OUString* pIter = aSeq.getConstArray(); + const OUString* pEnd = pIter + aSeq.getLength(); for(;pIter != pEnd;++pIter) { Reference< XStyle > xStyle; @@ -434,7 +430,7 @@ void XMLStyleExport::exportStyleFamily( xPropSet->getPropertySetInfo(); if( xPropSetInfo->hasPropertyByName( sFollowStyle ) ) - pExportedStyles.reset(new std::set<String>()); + pExportedStyles.reset(new std::set<OUString>()); bFirstStyle = sal_False; } @@ -487,7 +483,7 @@ void XMLStyleExport::exportStyleFamily( OUString sNextName; xPropSet->getPropertyValue( sFollowStyle ) >>= sNextName; - String sTmp( sNextName ); + OUString sTmp( sNextName ); // if the next style hasn't been exported by now, export it now // and remember its name. if( xStyle->getName() != sNextName && diff --git a/xmloff/source/style/xmlnumfe.cxx b/xmloff/source/style/xmlnumfe.cxx index 0eb79339ca6e..694d939386c5 100644 --- a/xmloff/source/style/xmlnumfe.cxx +++ b/xmloff/source/style/xmlnumfe.cxx @@ -1795,7 +1795,7 @@ sal_uInt32 SvXMLNumFmtExport::ForceSystemLanguage( sal_uInt32 nKey ) { DBG_ASSERT( pFormatter != NULL, "format without formatter?" ); - xub_StrLen nErrorPos; + sal_Int32 nErrorPos; short nType = pFormat->GetType(); sal_uInt32 nNewKey = pFormatter->GetFormatForLanguageIfBuiltIn( @@ -1807,7 +1807,7 @@ sal_uInt32 SvXMLNumFmtExport::ForceSystemLanguage( sal_uInt32 nKey ) } else { - String aFormatString( pFormat->GetFormatstring() ); + OUString aFormatString( pFormat->GetFormatstring() ); pFormatter->PutandConvertEntry( aFormatString, nErrorPos, nType, nNewKey, diff --git a/xmloff/source/style/xmlnumfi.cxx b/xmloff/source/style/xmlnumfi.cxx index b9a105d6a5dc..d53e004701dd 100644 --- a/xmloff/source/style/xmlnumfi.cxx +++ b/xmloff/source/style/xmlnumfi.cxx @@ -868,13 +868,12 @@ static void lcl_EnquoteIfNecessary( rtl::OUStringBuffer& rContent, const SvXMLNu if ( bQuote ) { // #i55469# quotes in the string itself have to be escaped - rtl::OUString aString( rContent.getStr() ); - bool bEscape = ( aString.indexOf( (sal_Unicode) '"' ) >= 0 ); + bool bEscape = ( rContent.indexOf( (sal_Unicode) '"' ) >= 0 ); if ( bEscape ) { // A quote is turned into "\"" - a quote to end quoted text, an escaped quote, // and a quote to resume quoting. - rtl::OUString aInsert( "\"\\\"" ); + OUString aInsert( "\"\\\"" ); sal_Int32 nPos = 0; while ( nPos < rContent.getLength() ) @@ -899,8 +898,7 @@ static void lcl_EnquoteIfNecessary( rtl::OUStringBuffer& rContent, const SvXMLNu rContent[0] == (sal_Unicode) '"' && rContent[1] == (sal_Unicode) '"' ) { - String aTrimmed( rContent.makeStringAndClear().copy(2) ); - rContent = rtl::OUStringBuffer( aTrimmed ); + rContent.remove(0, 2); } sal_Int32 nLen = rContent.getLength(); @@ -908,8 +906,7 @@ static void lcl_EnquoteIfNecessary( rtl::OUStringBuffer& rContent, const SvXMLNu rContent[nLen - 1] == (sal_Unicode) '"' && rContent[nLen - 2] == (sal_Unicode) '"' ) { - String aTrimmed( rContent.makeStringAndClear().copy( 0, nLen - 2 ) ); - rContent = rtl::OUStringBuffer( aTrimmed ); + rContent.remove(nLen - 2); } } } @@ -1632,14 +1629,14 @@ sal_Int32 SvXMLNumFormatContext::CreateAndInsert(SvNumberFormatter* pFormatter) { // insert by format string - String aFormatStr( sFormat ); + OUString aFormatStr( sFormat ); nIndex = pFormatter->GetEntryKey( aFormatStr, nFormatLang ); if ( nIndex == NUMBERFORMAT_ENTRY_NOT_FOUND ) { - xub_StrLen nErrPos = 0; + sal_Int32 nErrPos = 0; short l_nType = 0; sal_Bool bOk = pFormatter->PutEntry( aFormatStr, nErrPos, l_nType, nIndex, nFormatLang ); - if ( !bOk && nErrPos == 0 && aFormatStr != String(sFormat) ) + if ( !bOk && nErrPos == 0 && aFormatStr != sFormat ) { // if the string was modified by PutEntry, look for an existing format // with the modified string @@ -1682,8 +1679,7 @@ sal_Int32 SvXMLNumFormatContext::CreateAndInsert(SvNumberFormatter* pFormatter) SvNumberformat* pFormat = const_cast<SvNumberformat*>(pFormatter->GetEntry( nIndex )); if (pFormat) { - String sTitle (sFormatTitle); - pFormat->SetComment(sTitle); + pFormat->SetComment(sFormatTitle); } } @@ -1780,15 +1776,15 @@ void SvXMLNumFormatContext::AddNumber( const SvXMLNumberInfo& rInfo ) bGrouping = sal_False; // grouping and embedded characters can't be used together sal_uInt32 nStdIndex = pFormatter->GetStandardIndex( nFormatLang ); - String aNumStr = pFormatter->GenerateFormat( nStdIndex, nFormatLang, - bGrouping, sal_False, nGenPrec, nLeading ); + OUStringBuffer aNumStr = pFormatter->GenerateFormat( nStdIndex, nFormatLang, + bGrouping, sal_False, nGenPrec, nLeading ); if ( rInfo.nExpDigits >= 0 && nLeading == 0 && !bGrouping && nEmbeddedCount == 0 ) { // #i43959# For scientific numbers, "#" in the integer part forces a digit, // so it has to be removed if nLeading is 0 (".00E+0", not "#.00E+0"). - aNumStr = comphelper::string::stripStart(aNumStr, '#'); + aNumStr.stripStart((sal_Unicode)'#'); } if ( nEmbeddedCount ) @@ -1797,9 +1793,11 @@ void SvXMLNumFormatContext::AddNumber( const SvXMLNumberInfo& rInfo ) // only the integer part is supported // nZeroPos is the string position where format position 0 is inserted - xub_StrLen nZeroPos = aNumStr.Search( pData->GetLocaleData( nFormatLang ).getNumDecimalSep() ); - if ( nZeroPos == STRING_NOTFOUND ) - nZeroPos = aNumStr.Len(); + sal_Int32 nZeroPos = aNumStr.indexOf( pData->GetLocaleData( nFormatLang ).getNumDecimalSep() ); + if ( nZeroPos < 0 ) + { + nZeroPos = aNumStr.getLength(); + } // aEmbeddedElements is sorted - last entry has the largest position (leftmost) const SvXMLEmbeddedElement* pLastObj = &*rInfo.aEmbeddedElements.rbegin(); @@ -1809,10 +1807,11 @@ void SvXMLNumFormatContext::AddNumber( const SvXMLNumberInfo& rInfo ) // add '#' characters so all embedded texts are really embedded in digits // (there always has to be a digit before the leftmost embedded text) - xub_StrLen nAddCount = (xub_StrLen)nLastFormatPos + 1 - nZeroPos; - OUStringBuffer aDigitStr; - comphelper::string::padToLength(aDigitStr, nAddCount, (sal_Unicode)'#'); - aNumStr.Insert(aDigitStr.makeStringAndClear(), 0); + sal_Int32 nAddCount = nLastFormatPos + 1 - nZeroPos; + for(sal_Int32 index = 0; index < nAddCount; ++index) + { + aNumStr.insert(0, (sal_Unicode)'#'); + } nZeroPos = nZeroPos + nAddCount; } @@ -1825,18 +1824,17 @@ void SvXMLNumFormatContext::AddNumber( const SvXMLNumberInfo& rInfo ) sal_Int32 nInsertPos = nZeroPos - nFormatPos; if ( nFormatPos >= 0 && nInsertPos >= 0 ) { - rtl::OUStringBuffer aContent( pObj->aText ); // #107805# always quote embedded strings - even space would otherwise // be recognized as thousands separator in French. - aContent.insert( 0, (sal_Unicode) '"' ); - aContent.append( (sal_Unicode) '"' ); - aNumStr.Insert( String( aContent.makeStringAndClear() ), (xub_StrLen)nInsertPos ); + aNumStr.insert(nInsertPos, '"'); + aNumStr.insert(nInsertPos, pObj->aText); + aNumStr.insert(nInsertPos, '"'); } } } - aFormatCode.append( aNumStr ); + aFormatCode.append( aNumStr.makeStringAndClear() ); if ( ( rInfo.bDecReplace || rInfo.bVarDecimals ) && nPrec ) // add decimal replacement (dashes) { @@ -1948,7 +1946,7 @@ void SvXMLNumFormatContext::AddNfKeyword( sal_uInt16 nIndex ) bHasLongDoW = sal_True; // to remove string constant with separator } - String sKeyword = pFormatter->GetKeyword( nFormatLang, nIndex ); + OUString sKeyword = pFormatter->GetKeyword( nFormatLang, nIndex ); if ( nIndex == NF_KEY_H || nIndex == NF_KEY_HH || nIndex == NF_KEY_MI || nIndex == NF_KEY_MMI || @@ -1957,15 +1955,20 @@ void SvXMLNumFormatContext::AddNfKeyword( sal_uInt16 nIndex ) if ( !bTruncate && !bHasDateTime ) { // with truncate-on-overflow = false, add "[]" to first time part - - sKeyword.Insert( (sal_Unicode) '[', 0 ); - sKeyword.Append( (sal_Unicode) ']' ); + aFormatCode.append( (sal_Unicode)'[' ); + aFormatCode.append( sKeyword ); + aFormatCode.append( (sal_Unicode)']' ); + } + else + { + aFormatCode.append( sKeyword ); } bHasDateTime = sal_True; } - - aFormatCode.append( sKeyword ); - + else + { + aFormatCode.append( sKeyword ); + } // collect the date elements that the format contains, to recognize default date formats switch ( nIndex ) { @@ -1993,17 +1996,17 @@ void SvXMLNumFormatContext::AddNfKeyword( sal_uInt16 nIndex ) } } -static sal_Bool lcl_IsAtEnd( rtl::OUStringBuffer& rBuffer, const String& rToken ) +static sal_Bool lcl_IsAtEnd( rtl::OUStringBuffer& rBuffer, const OUString& rToken ) { sal_Int32 nBufLen = rBuffer.getLength(); - xub_StrLen nTokLen = rToken.Len(); + sal_Int32 nTokLen = rToken.getLength(); if ( nTokLen > nBufLen ) return sal_False; sal_Int32 nStartPos = nBufLen - nTokLen; - for ( xub_StrLen nTokPos = 0; nTokPos < nTokLen; nTokPos++ ) - if ( rToken.GetChar( nTokPos ) != rBuffer[nStartPos + nTokPos] ) + for ( sal_Int32 nTokPos = 0; nTokPos < nTokLen; nTokPos++ ) + if ( rToken[ nTokPos ] != rBuffer[nStartPos + nTokPos] ) return sal_False; return sal_True; @@ -2017,14 +2020,14 @@ sal_Bool SvXMLNumFormatContext::ReplaceNfKeyword( sal_uInt16 nOld, sal_uInt16 nN if (!pFormatter) return sal_False; - String sOldStr = pFormatter->GetKeyword( nFormatLang, nOld ); + OUString sOldStr = pFormatter->GetKeyword( nFormatLang, nOld ); if ( lcl_IsAtEnd( aFormatCode, sOldStr ) ) { // remove old keyword - aFormatCode.setLength( aFormatCode.getLength() - sOldStr.Len() ); + aFormatCode.setLength( aFormatCode.getLength() - sOldStr.getLength() ); // add new keyword - String sNewStr = pFormatter->GetKeyword( nFormatLang, nNew ); + OUString sNewStr = pFormatter->GetKeyword( nFormatLang, nNew ); aFormatCode.append( sNewStr ); return sal_True; // changed @@ -2034,8 +2037,8 @@ sal_Bool SvXMLNumFormatContext::ReplaceNfKeyword( sal_uInt16 nOld, sal_uInt16 nN void SvXMLNumFormatContext::AddCondition( const sal_Int32 nIndex ) { - rtl::OUString rApplyName = aMyConditions[nIndex].sMapName; - rtl::OUString rCondition = aMyConditions[nIndex].sCondition; + OUString rApplyName = aMyConditions[nIndex].sMapName; + OUString rCondition = aMyConditions[nIndex].sCondition; SvNumberFormatter* pFormatter = pData->GetNumberFormatter(); sal_uInt32 l_nKey = pData->GetKeyForName( rApplyName ); OUString sValue("value()"); //! define constant @@ -2067,10 +2070,13 @@ void SvXMLNumFormatContext::AddCondition( const sal_Int32 nIndex ) { sal_Int32 nPos = sRealCond.indexOf( '.' ); if ( nPos >= 0 ) - { // #i8026# #103991# localize decimal separator - const String& rDecSep = GetLocaleData().getNumDecimalSep(); - if ( rDecSep.Len() > 1 || rDecSep.GetChar(0) != '.' ) + { + // #i8026# #103991# localize decimal separator + const OUString& rDecSep = GetLocaleData().getNumDecimalSep(); + if ( rDecSep.getLength() > 1 || rDecSep[0] != '.' ) + { sRealCond = sRealCond.replaceAt( nPos, 1, rDecSep ); + } } aConditions.append( (sal_Unicode) '[' ); aConditions.append( sRealCond ); diff --git a/xmloff/source/style/xmlnumi.cxx b/xmloff/source/style/xmlnumi.cxx index 8f93f909e2df..9d0dec5ffc91 100644 --- a/xmloff/source/style/xmlnumi.cxx +++ b/xmloff/source/style/xmlnumi.cxx @@ -34,7 +34,6 @@ #include <tools/debug.hxx> #include <tools/fontenum.hxx> -#include <tools/string.hxx> #include <sax/tools/converter.hxx> @@ -55,9 +54,6 @@ #include <xmloff/xmlnumi.hxx> -using ::rtl::OUString; -using ::rtl::OUStringBuffer; - using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::style; @@ -69,9 +65,6 @@ using namespace ::com::sun::star::frame; using namespace ::xmloff::token; using namespace ::com::sun::star::io; -using rtl::OUString; -using rtl::OUStringBuffer; - static sal_Char const XML_UNO_NAME_NRULE_SYMBOL_TEXT_DISTANCE[] = "SymbolTextDistance"; static sal_Char const XML_UNO_NAME_NRULE_PARENT_NUMBERING[] = @@ -491,7 +484,7 @@ Sequence<beans::PropertyValue> SvxXMLListLevelStyleContext_Impl::GetProperties( || ((300 == nUPD) && (nBuildId <= 9573)))) { // #i93908# OOo < 3.4 wrote a bogus suffix for bullet chars - sSuffix = ::rtl::OUString(); // clear it + sSuffix = OUString(); // clear it } } diff --git a/xmloff/source/style/xmlstyle.cxx b/xmloff/source/style/xmlstyle.cxx index 5817e4ccce53..fe28e57d7bfe 100644 --- a/xmloff/source/style/xmlstyle.cxx +++ b/xmloff/source/style/xmlstyle.cxx @@ -56,8 +56,6 @@ #include <set> #include <vector> -using ::rtl::OUString; -using ::rtl::OUStringBuffer; using ::std::vector; using namespace ::com::sun::star; @@ -101,7 +99,7 @@ const SvXMLTokenMap& SvXMLStylesContext::GetStyleStylesElemTokenMap() void SvXMLStyleContext::SetAttribute( sal_uInt16 nPrefixKey, const OUString& rLocalName, - const OUString& rValue ) + const OUString& rValue ) { // TODO: use a map here if( XML_NAMESPACE_STYLE == nPrefixKey ) @@ -164,8 +162,8 @@ SvXMLStyleContext::~SvXMLStyleContext() } SvXMLImportContext *SvXMLStyleContext::CreateChildContext( sal_uInt16 nPrefix, - const OUString& rLocalName, - const uno::Reference< xml::sax::XAttributeList > & ) + const OUString& rLocalName, + const uno::Reference< xml::sax::XAttributeList > & ) { return new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); } @@ -290,7 +288,8 @@ public: void Clear(); const SvXMLStyleContext *FindStyleChildContext( sal_uInt16 nFamily, - const OUString& rName, sal_Bool bCreateIndex ) const; + const OUString& rName, + sal_Bool bCreateIndex ) const; sal_Bool IsAutomaticStyle() const { return bAutomaticStyle; } }; @@ -334,10 +333,9 @@ void SvXMLStylesContext_Impl::Clear() aStyles.clear(); } -const SvXMLStyleContext *SvXMLStylesContext_Impl::FindStyleChildContext( - sal_uInt16 nFamily, - const OUString& rName, - sal_Bool bCreateIndex ) const +const SvXMLStyleContext *SvXMLStylesContext_Impl::FindStyleChildContext( sal_uInt16 nFamily, + const OUString& rName, + sal_Bool bCreateIndex ) const { const SvXMLStyleContext *pStyle = 0; @@ -399,10 +397,9 @@ sal_Bool SvXMLStylesContext::IsAutomaticStyle() const return mpImpl->IsAutomaticStyle(); } -SvXMLStyleContext *SvXMLStylesContext::CreateStyleChildContext( - sal_uInt16 p_nPrefix, - const OUString& rLocalName, - const uno::Reference< xml::sax::XAttributeList > & xAttrList ) +SvXMLStyleContext *SvXMLStylesContext::CreateStyleChildContext( sal_uInt16 p_nPrefix, + const OUString& rLocalName, + const uno::Reference< xml::sax::XAttributeList > & xAttrList ) { SvXMLStyleContext *pStyle = NULL; @@ -566,8 +563,7 @@ sal_Bool SvXMLStylesContext::InsertStyleFamily( sal_uInt16 ) const return sal_True; } -sal_uInt16 SvXMLStylesContext::GetFamily( - const ::rtl::OUString& rValue ) const +sal_uInt16 SvXMLStylesContext::GetFamily( const OUString& rValue ) const { sal_uInt16 nFamily = 0U; if( IsXMLToken( rValue, XML_PARAGRAPH ) ) @@ -716,9 +712,7 @@ Reference < XAutoStyleFamily > SvXMLStylesContext::GetAutoStyles( sal_uInt16 nFa xAutoStyles = mxParaAutoStyles; else { - sName = bPara ? - OUString( RTL_CONSTASCII_USTRINGPARAM( "ParagraphStyles" ) ): - OUString( RTL_CONSTASCII_USTRINGPARAM( "CharacterStyles" ) ); + sName = bPara ? OUString( "ParagraphStyles" ): OUString( "CharacterStyles" ); Reference< XAutoStylesSupplier > xAutoStylesSupp( GetImport().GetModel(), UNO_QUERY ); Reference< XAutoStyles > xAutoStyleFamilies = xAutoStylesSupp->getAutoStyles(); if (xAutoStyleFamilies->hasByName(sName)) @@ -746,16 +740,14 @@ Reference < XNameContainer > SvXMLStylesContext::GetStylesContainer( if( mxParaStyles.is() ) xStyles = mxParaStyles; else - sName = - OUString( RTL_CONSTASCII_USTRINGPARAM( "ParagraphStyles" ) ); + sName = "ParagraphStyles"; break; case XML_STYLE_FAMILY_TEXT_TEXT: if( mxTextStyles.is() ) xStyles = mxTextStyles; else - sName = - OUString( RTL_CONSTASCII_USTRINGPARAM( "CharacterStyles" ) ); + sName = "CharacterStyles"; break; } if( !xStyles.is() && !sName.isEmpty() ) @@ -788,7 +780,7 @@ Reference < XNameContainer > SvXMLStylesContext::GetStylesContainer( OUString SvXMLStylesContext::GetServiceName( sal_uInt16 nFamily ) const { - String sServiceName; + OUString sServiceName; switch( nFamily ) { case XML_STYLE_FAMILY_TEXT_PARAGRAPH: @@ -822,8 +814,8 @@ SvXMLStylesContext::~SvXMLStylesContext() } SvXMLImportContext *SvXMLStylesContext::CreateChildContext( sal_uInt16 nPrefix, - const OUString& rLocalName, - const uno::Reference< xml::sax::XAttributeList > & xAttrList ) + const OUString& rLocalName, + const uno::Reference< xml::sax::XAttributeList > & xAttrList ) { SvXMLImportContext *pContext = 0; |