[Libreoffice-commits] core.git: filter/source

Marcos Paulo de Souza marcos.souza.org at gmail.com
Sat Feb 16 09:19:56 PST 2013


 filter/source/msfilter/msvbahelper.cxx   |    8 ++------
 filter/source/msfilter/svdfppt.cxx       |   16 ++++++----------
 filter/source/pdf/pdfexport.cxx          |    5 +----
 filter/source/svg/svgwriter.cxx          |    6 ++----
 filter/source/svg/test/odfserializer.cxx |   23 +++++------------------
 filter/source/xsltfilter/XSLTFilter.cxx  |    4 +---
 6 files changed, 17 insertions(+), 45 deletions(-)

New commits:
commit 92064bb2c265069de33d0ced7aa9d94d4c2829c3
Author: Marcos Paulo de Souza <marcos.souza.org at gmail.com>
Date:   Sat Feb 16 13:53:59 2013 -0200

    fdo#57950: Remove more chained appends in filter
    
    And also sanitize some OUStringBuffer uses.
    
    Change-Id: I338b18981e1f925d76c0d640159de30bab219122
    Reviewed-on: https://gerrit.libreoffice.org/2186
    Reviewed-by: Olivier Hallot <olivier.hallot at alta.org.br>
    Tested-by: Olivier Hallot <olivier.hallot at alta.org.br>

diff --git a/filter/source/msfilter/msvbahelper.cxx b/filter/source/msfilter/msvbahelper.cxx
index 9b8353d..e143ba4 100644
--- a/filter/source/msfilter/msvbahelper.cxx
+++ b/filter/source/msfilter/msvbahelper.cxx
@@ -48,11 +48,7 @@ const OUString sUrlPart1( "?language=Basic&location=document" );
 
 OUString makeMacroURL( const OUString& sMacroName )
 {
-    return OUStringBuffer().
-        append( sUrlPart0 ).
-        append( sMacroName ).
-        append( sUrlPart1 ).
-        makeStringAndClear();
+    return sUrlPart0 + sMacroName + sUrlPart1;
 }
 
 OUString extractMacroName( const OUString& rMacroUrl )
@@ -282,7 +278,7 @@ OUString resolveVBAMacro( SfxObjectShell* pShell, const OUString& rLibName, cons
         OUString aLibName = rLibName.isEmpty() ?  getDefaultProjectName( pShell ) : rLibName ;
         OUString aModuleName = rModuleName;
         if( hasMacro( pShell, aLibName, aModuleName, rMacroName ) )
-            return OUStringBuffer( aLibName ).append( sal_Unicode( '.' ) ).append( aModuleName ).append( sal_Unicode( '.' ) ).append( rMacroName ).makeStringAndClear();
+            return aLibName + "." + aModuleName + "." + rMacroName;
     }
 #endif
     return OUString();
diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index 057f7e5..b307db4 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -4110,24 +4110,20 @@ PPTStyleSheet::PPTStyleSheet( const DffRecordHeader& rSlideHd, SvStream& rIn, Sd
             {
                 if ( rIn.GetError() == 0 )
                 {
-                    rtl::OStringBuffer aMsg;
+                    OStringBuffer aMsg;
                     if ( rIn.Tell() > aTxMasterStyleHd.GetRecEndFilePos() )
                     {
-                        aMsg.append(RTL_CONSTASCII_STRINGPARAM("\n  "));
-                        aMsg.append(RTL_CONSTASCII_STRINGPARAM("reading too many bytes:"));
-                        aMsg.append(static_cast<sal_Int32>(rIn.Tell() - aTxMasterStyleHd.GetRecEndFilePos()));
+                        aMsg.append("\n  " + "reading too many bytes:" +
+                                    OString::number(rIn.Tell() - aTxMasterStyleHd.GetRecEndFilePos()));
                     }
                     if ( rIn.Tell() < aTxMasterStyleHd.GetRecEndFilePos() )
                     {
-                        aMsg.append(RTL_CONSTASCII_STRINGPARAM("\n  "));
-                        aMsg.append(RTL_CONSTASCII_STRINGPARAM("reading too few bytes:"));
-                        aMsg.append(static_cast<sal_Int32>(aTxMasterStyleHd.GetRecEndFilePos() - rIn.Tell()));
+                        aMsg.append("\n  " + "reading too few bytes:" +
+                                    OString::number(aTxMasterStyleHd.GetRecEndFilePos() - rIn.Tell()));
                     }
                     if (aMsg.getLength())
                     {
-                        aMsg.insert(0, RTL_CONSTASCII_STRINGPARAM("]:"));
-                        aMsg.insert(0, RTL_CONSTASCII_STRINGPARAM(
-                            "PptStyleSheet::operator>>["));
+                        aMsg.insert(0, "PptStyleSheet::operator>>[]");
                         OSL_FAIL(aMsg.getStr());
                     }
                 }
diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx
index c9f3133..57d538b 100644
--- a/filter/source/pdf/pdfexport.cxx
+++ b/filter/source/pdf/pdfexport.cxx
@@ -878,10 +878,7 @@ sal_Bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue
 
                 if( aPageRange.isEmpty() )
                 {
-                    aPageRange = OUStringBuffer()
-                        .append( static_cast< sal_Int32 >( 1 ) )
-                        .append( static_cast< sal_Unicode >( '-' ) )
-                        .append( nPageCount ).makeStringAndClear();
+                    aPageRange = OUString::number( 1 ) + "-" + OUString::number(nPageCount );
                 }
                 StringRangeEnumerator aRangeEnum( aPageRange, 0, nPageCount-1 );
 
diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx
index 8ba1446..14e115e 100644
--- a/filter/source/svg/svgwriter.cxx
+++ b/filter/source/svg/svgwriter.cxx
@@ -2935,8 +2935,7 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf,
             {
                 SvXMLElementExport aElem( mrExport,
                         XML_NAMESPACE_NONE, "desc", sal_False, sal_False );
-                OUStringBuffer sType;
-                sType.append(static_cast<sal_Int32>(nType));
+                OUStringBuffer sType(OUString::number(nType));
                 if (pAction && (nType == META_COMMENT_ACTION))
                 {
                     sType.append(": ");
@@ -2944,9 +2943,8 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf,
                     rtl::OString sComment = pA->GetComment();
                     if (!sComment.isEmpty())
                     {
-                        OUString ssComment = OUString( sComment.getStr(),
+                        sType.append(OUString( sComment.getStr(),
                                 sComment.getLength(), RTL_TEXTENCODING_UTF8 );
-                        sType.append(ssComment);
                     }
                     if (sComment.equalsIgnoreAsciiCaseL(
                                 RTL_CONSTASCII_STRINGPARAM("FIELD_SEQ_BEGIN")))
diff --git a/filter/source/svg/test/odfserializer.cxx b/filter/source/svg/test/odfserializer.cxx
index 77c9971..fbba017 100644
--- a/filter/source/svg/test/odfserializer.cxx
+++ b/filter/source/svg/test/odfserializer.cxx
@@ -76,32 +76,19 @@ void SAL_CALL ODFSerializer::endDocument() throw (xml::sax::SAXException, uno::R
 void SAL_CALL ODFSerializer::startElement( const ::rtl::OUString& aName,
                                            const uno::Reference< xml::sax::XAttributeList >& xAttribs ) throw (xml::sax::SAXException, uno::RuntimeException)
 {
-    rtl::OUStringBuffer aElement;
-    aElement.appendAscii("<");
-    aElement.append(aName);
-    aElement.appendAscii(" ");
+    OUStringBuffer aElement("<" + aName + " ");
 
     const sal_Int16 nLen=xAttribs->getLength();
     for( sal_Int16 i=0; i<nLen; ++i )
-    {
-        rtl::OUStringBuffer aAttribute;
-        aElement.append(xAttribs->getNameByIndex(i));
-        aElement.appendAscii("=\"");
-        aElement.append(xAttribs->getValueByIndex(i));
-        aElement.appendAscii("\" ");
-    }
+        aElement.append(xAttribs->getNameByIndex(i) + "=\"" +
+                        xAttribs->getValueByIndex(i) + "\" ");
 
-    aElement.appendAscii(">");
-    characters(aElement.makeStringAndClear());
+    characters(aElement.makeStringAndClear() + ">");
 }
 
 void SAL_CALL ODFSerializer::endElement( const ::rtl::OUString& aName ) throw (xml::sax::SAXException, uno::RuntimeException)
 {
-    rtl::OUStringBuffer aElement;
-    aElement.appendAscii("</");
-    aElement.append(aName);
-    aElement.appendAscii(">");
-    characters(aElement.makeStringAndClear());
+    characters("</" + aName + ">");
 }
 
 void SAL_CALL ODFSerializer::characters( const ::rtl::OUString& aChars ) throw (xml::sax::SAXException, uno::RuntimeException)
diff --git a/filter/source/xsltfilter/XSLTFilter.cxx b/filter/source/xsltfilter/XSLTFilter.cxx
index 30f7e0d..a16627f 100644
--- a/filter/source/xsltfilter/XSLTFilter.cxx
+++ b/filter/source/xsltfilter/XSLTFilter.cxx
@@ -241,9 +241,7 @@ m_rServiceFactory(r), m_bTerminated(sal_False), m_bError(sal_False)
         Exception e;
         if (a >>= e)
         {
-            rtl::OStringBuffer aMessage(RTL_CONSTASCII_STRINGPARAM("XSLTFilter::error was called: "));
-            aMessage.append(rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US));
-            OSL_FAIL(aMessage.getStr());
+            OSL_FAIL("XSLTFilter::error was called: " + OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US));
         }
         m_bError = sal_True;
         osl_setCondition(m_cTransformed);


More information about the Libreoffice-commits mailing list