diff options
23 files changed, 73 insertions, 68 deletions
diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx index 9da8710c328a..16a3833eeea2 100644 --- a/editeng/source/outliner/outliner.cxx +++ b/editeng/source/outliner/outliner.cxx @@ -1641,7 +1641,7 @@ EBulletInfo Outliner::GetBulletInfo( sal_Int32 nPara ) OUString Outliner::GetText( Paragraph const * pParagraph, sal_Int32 nCount ) const { - OUStringBuffer aText; + OUStringBuffer aText(128); sal_Int32 nStartPara = pParaList->GetAbsPos( pParagraph ); for ( sal_Int32 n = 0; n < nCount; n++ ) { diff --git a/include/xmloff/xmlnumfi.hxx b/include/xmloff/xmlnumfi.hxx index de071b6ec624..4a1eaca5b256 100644 --- a/include/xmloff/xmlnumfi.hxx +++ b/include/xmloff/xmlnumfi.hxx @@ -132,8 +132,8 @@ class XMLOFF_DLLPUBLIC SvXMLNumFormatContext : public SvXMLStyleContext bool bAutoDec; // set in AddNumber bool bAutoInt; // set in AddNumber bool bHasExtraText; - OUStringBuffer aFormatCode; - OUStringBuffer aConditions; + OUStringBuffer aFormatCode{64}; + OUStringBuffer aConditions{32}; bool bHasLongDoW; bool bHasEra; bool bHasDateTime; diff --git a/include/xmloff/xmluconv.hxx b/include/xmloff/xmluconv.hxx index cc7c4736e6c7..d791f6cb633d 100644 --- a/include/xmloff/xmluconv.hxx +++ b/include/xmloff/xmluconv.hxx @@ -119,6 +119,9 @@ public: void convertMeasureToXML( OUStringBuffer& rBuffer, sal_Int32 nMeasure ) const; + /** convert measure to string: from meCoreMeasureUnit to meXMLMeasureUnit */ + OUString convertMeasureToXML( sal_Int32 nMeasure ) const; + /** convert string to enum using given enum map, if the enum is not found in the map, this method will return false */ template<typename EnumT> diff --git a/oox/source/core/relationshandler.cxx b/oox/source/core/relationshandler.cxx index 9b7675ff2cb1..fe448bc43a7b 100644 --- a/oox/source/core/relationshandler.cxx +++ b/oox/source/core/relationshandler.cxx @@ -45,12 +45,10 @@ namespace { OUString lclGetRelationsPath( const OUString& rFragmentPath ) { sal_Int32 nPathLen = ::std::max< sal_Int32 >( rFragmentPath.lastIndexOf( '/' ) + 1, 0 ); - return - OUStringBuffer( rFragmentPath.copy( 0, nPathLen ) ). // file path including slash - append( "_rels/" ). // additional '_rels/' path - append( std::u16string_view(rFragmentPath).substr(nPathLen) ). // file name after path - append( ".rels" ). // '.rels' suffix - makeStringAndClear(); + return rtl::OUStringView(rFragmentPath.getStr(), nPathLen ) + // file path including slash + "_rels/" + // additional '_rels/' path + rtl::OUStringView(rFragmentPath.getStr() + nPathLen) + // file name after path + ".rels"; // '.rels' suffix } } // namespace diff --git a/oox/source/ole/olehelper.cxx b/oox/source/ole/olehelper.cxx index d2dd4899d2e6..05b787d9f85a 100644 --- a/oox/source/ole/olehelper.cxx +++ b/oox/source/ole/olehelper.cxx @@ -261,7 +261,7 @@ void OleHelper::exportGuid( BinaryOutputStream& rOStr, const SvGlobalName& rId ) OUString OleHelper::importGuid( BinaryInputStream& rInStrm ) { - OUStringBuffer aBuffer; + OUStringBuffer aBuffer(40); aBuffer.append( '{' ); lclAppendHex( aBuffer, rInStrm.readuInt32() ); aBuffer.append( '-' ); diff --git a/oox/source/ole/vbamodule.cxx b/oox/source/ole/vbamodule.cxx index b7ff5edb7aec..82a368934794 100644 --- a/oox/source/ole/vbamodule.cxx +++ b/oox/source/ole/vbamodule.cxx @@ -143,7 +143,7 @@ void VbaModule::createEmptyModule( const Reference< container::XNameContainer >& OUString VbaModule::readSourceCode( StorageBase& rVbaStrg ) const { - OUStringBuffer aSourceCode; + OUStringBuffer aSourceCode(512); static const char sUnmatchedRemovedTag[] = "Rem removed unmatched Sub/End: "; if( !maStreamName.isEmpty() && (mnOffset != SAL_MAX_UINT32) ) { @@ -264,7 +264,7 @@ void VbaModule::createModule( const OUString& rVBASourceCode, // prepare the Basic module script::ModuleInfo aModuleInfo; aModuleInfo.ModuleType = mnType; - OUStringBuffer aSourceCode; + OUStringBuffer aSourceCode(512); aSourceCode.append( "Rem Attribute VBA_ModuleType=" ); switch( mnType ) { diff --git a/sc/source/core/tool/calcconfig.cxx b/sc/source/core/tool/calcconfig.cxx index 6bafa226e8b5..9f9bf35bacc0 100644 --- a/sc/source/core/tool/calcconfig.cxx +++ b/sc/source/core/tool/calcconfig.cxx @@ -193,7 +193,7 @@ bool ScCalcConfig::operator!= (const ScCalcConfig& r) const OUString ScOpCodeSetToSymbolicString(const ScCalcConfig::OpCodeSet& rOpCodes) { - OUStringBuffer result; + OUStringBuffer result(256); formula::FormulaCompiler aCompiler; formula::FormulaCompiler::OpCodeMapPtr pOpCodeMap(aCompiler.GetOpCodeMap(css::sheet::FormulaLanguage::ENGLISH)); diff --git a/sc/source/core/tool/userlist.cxx b/sc/source/core/tool/userlist.cxx index 96e6983ac712..60d6a163ec60 100644 --- a/sc/source/core/tool/userlist.cxx +++ b/sc/source/core/tool/userlist.cxx @@ -212,7 +212,7 @@ ScUserList::ScUserList() xCal = rCalendar.Days; if ( xCal.hasElements() ) { - OUStringBuffer aDayShortBuf, aDayLongBuf; + OUStringBuffer aDayShortBuf(32), aDayLongBuf(64); sal_Int32 i; sal_Int32 nLen = xCal.getLength(); sal_Int16 nStart = sal::static_int_cast<sal_Int16>(nLen); @@ -244,7 +244,7 @@ ScUserList::ScUserList() xCal = rCalendar.Months; if ( xCal.hasElements() ) { - OUStringBuffer aMonthShortBuf, aMonthLongBuf; + OUStringBuffer aMonthShortBuf(128), aMonthLongBuf(128); sal_Int32 i; sal_Int32 nLen = xCal.getLength() - 1; for (i = 0; i < nLen; i++) diff --git a/sc/source/filter/excel/xipage.cxx b/sc/source/filter/excel/xipage.cxx index 29110f79b363..db8f4377a1c2 100644 --- a/sc/source/filter/excel/xipage.cxx +++ b/sc/source/filter/excel/xipage.cxx @@ -224,17 +224,15 @@ void XclImpPageSettings::Finalize() // *** create page style sheet *** - OUStringBuffer aStyleName; - aStyleName.append("PageStyle_"); - + OUString aStyleName; OUString aTableName; if( GetDoc().GetName( nScTab, aTableName ) ) - aStyleName.append(aTableName); + aStyleName = "PageStyle_" + aTableName; else - aStyleName.append(static_cast<sal_Int32>(nScTab+1)); + aStyleName = "PageStyle_" + OUString::number(static_cast<sal_Int32>(nScTab+1)); ScStyleSheet& rStyleSheet = ScfTools::MakePageStyleSheet( - GetStyleSheetPool(), aStyleName.makeStringAndClear(), false); + GetStyleSheetPool(), aStyleName, false); SfxItemSet& rItemSet = rStyleSheet.GetItemSet(); diff --git a/sc/source/filter/excel/xistream.cxx b/sc/source/filter/excel/xistream.cxx index 8e48027cdf1b..f7427b9295ed 100644 --- a/sc/source/filter/excel/xistream.cxx +++ b/sc/source/filter/excel/xistream.cxx @@ -831,7 +831,7 @@ std::size_t XclImpStream::ReadUniStringExtHeader( bool& rb16Bit, sal_uInt8 nFlag OUString XclImpStream::ReadRawUniString( sal_uInt16 nChars, bool b16Bit ) { - OUStringBuffer aRet; + OUStringBuffer aRet(nChars); sal_uInt16 nCharsLeft = nChars; sal_uInt16 nReadSize; diff --git a/sc/source/filter/xml/xmlcelli.hxx b/sc/source/filter/xml/xmlcelli.hxx index d80cfa759619..10aeb2dda44a 100644 --- a/sc/source/filter/xml/xmlcelli.hxx +++ b/sc/source/filter/xml/xmlcelli.hxx @@ -68,7 +68,7 @@ class ScXMLTableRowCellContext : public ScXMLImportContext boost::optional<OUString> maFirstParagraph; /// unformatted first paragraph, for better performance. ScEditEngineDefaulter* mpEditEngine; - OUStringBuffer maParagraph; + OUStringBuffer maParagraph{32}; sal_Int32 mnCurParagraph; ParaFormatsType maFormats; diff --git a/sfx2/source/appl/linkmgr2.cxx b/sfx2/source/appl/linkmgr2.cxx index 3109ac7ff28a..4f9c109a23d1 100644 --- a/sfx2/source/appl/linkmgr2.cxx +++ b/sfx2/source/appl/linkmgr2.cxx @@ -452,7 +452,7 @@ void LinkManager::InsertFileLink( if (!(OBJECT_CLIENT_SO & rLink.GetObjType())) return; - OUStringBuffer aBuf; + OUStringBuffer aBuf(64); aBuf.append(rFileNm); aBuf.append(sfx2::cTokenSeparator); diff --git a/sfx2/source/doc/SfxDocumentMetaData.cxx b/sfx2/source/doc/SfxDocumentMetaData.cxx index ad5417688fdc..8e6bf6f29c39 100644 --- a/sfx2/source/doc/SfxDocumentMetaData.cxx +++ b/sfx2/source/doc/SfxDocumentMetaData.cxx @@ -509,7 +509,7 @@ dateTimeToText(css::util::DateTime const& i_rdt, sal_Int16 const*const pTimeZone = nullptr) throw () { if (isValidDateTime(i_rdt)) { - OUStringBuffer buf; + OUStringBuffer buf(32); ::sax::Converter::convertDateTime(buf, i_rdt, pTimeZone, true); return buf.makeStringAndClear(); } else { diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index 09e6d59129f3..6dea1bc3d125 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -213,7 +213,7 @@ void SfxLokHelper::notifyWindow(const SfxViewShell* pThisView, void SfxLokHelper::notifyInvalidation(SfxViewShell const* pThisView, const OString& rPayload) { - OStringBuffer aBuf; + OStringBuffer aBuf(32); aBuf.append(rPayload); if (comphelper::LibreOfficeKit::isPartInInvalidation()) { diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index e7b430b20986..eb2b47dc80af 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -1647,7 +1647,7 @@ short SvNumberformat::ImpNextSymbol(OUStringBuffer& rString, sal_Unicode cLetter = ' '; // Preliminary result sal_Int32 nLen = rString.getLength(); ScanState eState = SsStart; - OUStringBuffer sBuffSymbol(64); + OUStringBuffer sBuffSymbol(128); const NfKeywordTable & rKeywords = rScan.GetKeywords(); while (nPos < nLen && eState != SsStop) diff --git a/tools/source/debug/debug.cxx b/tools/source/debug/debug.cxx index 3ab901c1aee9..6bfb9a42612f 100644 --- a/tools/source/debug/debug.cxx +++ b/tools/source/debug/debug.cxx @@ -398,7 +398,7 @@ static void exceptionToStringImpl(OStringBuffer& sMessage, const css::uno::Any & OString exceptionToString(const css::uno::Any & caught) { - OStringBuffer sMessage; + OStringBuffer sMessage(512); exceptionToStringImpl(sMessage, caught); return sMessage.makeStringAndClear(); } diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx index 636bfe42ff32..e07cfd04035e 100644 --- a/tools/source/fsys/urlobj.cxx +++ b/tools/source/fsys/urlobj.cxx @@ -1369,7 +1369,7 @@ bool INetURLObject::setAbsURIRef(OUString const & rTheAbsURIRef, } break; } - OUStringBuffer aSynHost; + OUStringBuffer aSynHost(64); if (!parseHostOrNetBiosName( pHostPortBegin, pPort, eMechanism, eCharset, bNetBiosName, &aSynHost)) @@ -1614,7 +1614,7 @@ bool INetURLObject::convertRelToAbs(OUString const & rTheRelURIRef, enum State { STATE_AUTH, STATE_ABS_PATH, STATE_REL_PATH, STATE_FRAGMENT, STATE_DONE }; - OUStringBuffer aSynAbsURIRef; + OUStringBuffer aSynAbsURIRef(128); // make sure that the scheme is copied for generic schemes: getSchemeInfo().m_pScheme // is empty ("") in that case, so take the scheme from m_aAbsURIRef if (m_eScheme != INetProtocol::Generic) @@ -2342,7 +2342,7 @@ bool INetURLObject::parseHost(sal_Unicode const *& rBegin, sal_Unicode const * p STATE_IP6_HEXSEQ1_MAYBE_IP4, STATE_IP6_HEXSEQ2, STATE_IP6_HEXSEQ2_COLON, STATE_IP6_HEXSEQ2_MAYBE_IP4, STATE_IP6_IP4, STATE_IP6_IP4_DOT, STATE_IP6_DONE }; - OUStringBuffer aTheCanonic; + OUStringBuffer aTheCanonic(32); sal_uInt32 nNumber = 0; int nDigits = 0; int nOctets = 0; @@ -4320,7 +4320,7 @@ OUString INetURLObject::getFSysPath(FSysStyle eStyle, if (pDelimiter) *pDelimiter = '\\'; - OUStringBuffer aSynFSysPath; + OUStringBuffer aSynFSysPath(64); if (m_aHost.isPresent() && m_aHost.getLength() > 0) { aSynFSysPath.append("\\\\"); diff --git a/unotools/source/config/docinfohelper.cxx b/unotools/source/config/docinfohelper.cxx index cf77b11404d8..7e605d187c75 100644 --- a/unotools/source/config/docinfohelper.cxx +++ b/unotools/source/config/docinfohelper.cxx @@ -30,7 +30,7 @@ namespace utl OUString DocInfoHelper::GetGeneratorString() { - OUStringBuffer aResult; + OUStringBuffer aResult(128); // First product: branded name + version // version is <product_versions>_<product_extension>$<platform> diff --git a/unotools/source/misc/datetime.cxx b/unotools/source/misc/datetime.cxx index 7b2ef0eb2c40..ca5c2c110057 100644 --- a/unotools/source/misc/datetime.cxx +++ b/unotools/source/misc/datetime.cxx @@ -259,7 +259,7 @@ void typeConvert(const css::util::DateTime& _rDateTime, DateTime& _rOut) OUString toISO8601(const css::util::DateTime& rDateTime) { - OUStringBuffer rBuffer; + OUStringBuffer rBuffer(32); rBuffer.append(static_cast<sal_Int32>(rDateTime.Year)); rBuffer.append('-'); if( rDateTime.Month < 10 ) diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index 2fbd6795394c..824caae1698f 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -167,9 +167,10 @@ OString GraphicID::getIDString() const { static const char aHexData[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; - OStringBuffer aHexStr; sal_Int32 nShift, nIndex = 0; - aHexStr.setLength(24 + (2 * BITMAP_CHECKSUM_SIZE)); + sal_Int32 nLen = 24 + (2 * BITMAP_CHECKSUM_SIZE); + OStringBuffer aHexStr(nLen); + aHexStr.setLength(nLen); for( nShift = 28; nShift >= 0; nShift -= 4 ) aHexStr[nIndex++] = aHexData[ ( mnID1 >> static_cast<sal_uInt32>(nShift) ) & 0xf ]; diff --git a/vcl/source/uitest/logger.cxx b/vcl/source/uitest/logger.cxx index 858dd0353d14..d7fd1dcf7392 100644 --- a/vcl/source/uitest/logger.cxx +++ b/vcl/source/uitest/logger.cxx @@ -309,7 +309,8 @@ OUString StringMapToOUString(const std::map<OUString, OUString>& rParameters) if (rParameters.empty()) return ""; - OUStringBuffer aParameterString = " {"; + OUStringBuffer aParameterString(static_cast<int>(rParameters.size()*32)); + aParameterString.append(" {"); for (std::map<OUString, OUString>::const_iterator itr = rParameters.begin(); itr != rParameters.end(); ++itr) diff --git a/xmloff/source/core/xmluconv.cxx b/xmloff/source/core/xmluconv.cxx index dcfae65672f1..dfff05c31f7e 100644 --- a/xmloff/source/core/xmluconv.cxx +++ b/xmloff/source/core/xmluconv.cxx @@ -185,6 +185,16 @@ void SvXMLUnitConverter::convertMeasureToXML( OUStringBuffer& rString, m_pImpl->m_eXMLMeasureUnit ); } +/** convert measure to string */ +OUString SvXMLUnitConverter::convertMeasureToXML( sal_Int32 nMeasure ) const +{ + OUStringBuffer s; + ::sax::Converter::convertMeasure( s, nMeasure, + m_pImpl->m_eCoreMeasureUnit, + m_pImpl->m_eXMLMeasureUnit ); + return s.makeStringAndClear(); +} + /** convert string to enum using given enum map, if the enum is not found in the map, this method will return false */ @@ -733,7 +743,7 @@ OUString SvXMLUnitConverter::encodeStyleName( *pEncoded = false; sal_Int32 nLen = rName.getLength(); - OUStringBuffer aBuffer( nLen ); + OUStringBuffer aBuffer( nLen*2 ); for( sal_Int32 i = 0; i < nLen; i++ ) { diff --git a/xmloff/source/style/xmlnume.cxx b/xmloff/source/style/xmlnume.cxx index e9908c8991a5..0f5a45dc40da 100644 --- a/xmloff/source/style/xmlnume.cxx +++ b/xmloff/source/style/xmlnume.cxx @@ -344,31 +344,26 @@ void SvxXMLNumRuleExport::exportLevelStyle( sal_Int32 nLevel, SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT, eElem, true, true ); - OUStringBuffer sBuffer; if ( ePosAndSpaceMode == PositionAndSpaceMode::LABEL_WIDTH_AND_POSITION ) { nSpaceBefore += nMinLabelWidth; nMinLabelWidth = -nMinLabelWidth; if( nSpaceBefore != 0 ) { - GetExport().GetMM100UnitConverter().convertMeasureToXML( - sBuffer, nSpaceBefore ); - GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_SPACE_BEFORE, - sBuffer.makeStringAndClear() ); + OUString sAttr = GetExport().GetMM100UnitConverter().convertMeasureToXML( + nSpaceBefore ); + GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_SPACE_BEFORE, sAttr ); } if( nMinLabelWidth != 0 ) { - GetExport().GetMM100UnitConverter().convertMeasureToXML( - sBuffer, nMinLabelWidth ); - GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_MIN_LABEL_WIDTH, - sBuffer.makeStringAndClear() ); + OUString s = GetExport().GetMM100UnitConverter().convertMeasureToXML( nMinLabelWidth ); + GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_MIN_LABEL_WIDTH, s); } if( nMinLabelDist > 0 ) { - GetExport().GetMM100UnitConverter().convertMeasureToXML( - sBuffer, nMinLabelDist ); - GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_MIN_LABEL_DISTANCE, - sBuffer.makeStringAndClear() ); + OUString sAttr = GetExport().GetMM100UnitConverter().convertMeasureToXML( + nMinLabelDist ); + GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_MIN_LABEL_DISTANCE, sAttr); } } /* Check, if properties for position-and-space-mode LABEL_ALIGNMENT @@ -443,18 +438,16 @@ void SvxXMLNumRuleExport::exportLevelStyle( sal_Int32 nLevel, if( nImageWidth > 0 ) { - GetExport().GetMM100UnitConverter().convertMeasureToXML( - sBuffer, nImageWidth ); - GetExport().AddAttribute( XML_NAMESPACE_FO, XML_WIDTH, - sBuffer.makeStringAndClear() ); + OUString sAttr = GetExport().GetMM100UnitConverter().convertMeasureToXML( + nImageWidth ); + GetExport().AddAttribute( XML_NAMESPACE_FO, XML_WIDTH, sAttr ); } if( nImageHeight > 0 ) { - GetExport().GetMM100UnitConverter().convertMeasureToXML( - sBuffer, nImageHeight ); - GetExport().AddAttribute( XML_NAMESPACE_FO, XML_HEIGHT, - sBuffer.makeStringAndClear() ); + OUString sAttr = GetExport().GetMM100UnitConverter().convertMeasureToXML( + nImageHeight ); + GetExport().AddAttribute( XML_NAMESPACE_FO, XML_HEIGHT, sAttr ); } } @@ -490,29 +483,29 @@ void SvxXMLNumRuleExport::exportLevelStyle( sal_Int32 nLevel, if ( eLabelFollowedBy == LabelFollow::LISTTAB && nListtabStopPosition > 0 ) { - GetExport().GetMM100UnitConverter().convertMeasureToXML( - sBuffer, nListtabStopPosition ); + OUString sAttr = GetExport().GetMM100UnitConverter().convertMeasureToXML( + nListtabStopPosition ); GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_LIST_TAB_STOP_POSITION, - sBuffer.makeStringAndClear() ); + sAttr ); } if ( nFirstLineIndent != 0 ) { - GetExport().GetMM100UnitConverter().convertMeasureToXML( - sBuffer, nFirstLineIndent ); + OUString sAttr = GetExport().GetMM100UnitConverter().convertMeasureToXML( + nFirstLineIndent ); GetExport().AddAttribute( XML_NAMESPACE_FO, XML_TEXT_INDENT, - sBuffer.makeStringAndClear() ); + sAttr ); } if ( nIndentAt != 0 ) { - GetExport().GetMM100UnitConverter().convertMeasureToXML( - sBuffer, nIndentAt ); + OUString sAttr = GetExport().GetMM100UnitConverter().convertMeasureToXML( + nIndentAt ); GetExport().AddAttribute( XML_NAMESPACE_FO, XML_MARGIN_LEFT, - sBuffer.makeStringAndClear() ); + sAttr ); } SvXMLElementExport aLabelAlignmentElement( GetExport(), XML_NAMESPACE_STYLE, @@ -582,6 +575,7 @@ void SvxXMLNumRuleExport::exportLevelStyle( sal_Int32 nLevel, } else { + OUStringBuffer sBuffer; ::sax::Converter::convertColor( sBuffer, nColor ); GetExport().AddAttribute( XML_NAMESPACE_FO, XML_COLOR, sBuffer.makeStringAndClear() ); |