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

Jelle van der Waa jelle at vdwaa.nl
Fri Aug 16 04:08:10 PDT 2013


 xmlscript/source/xmldlg_imexp/xmldlg_export.cxx |   35 ++++--------------------
 xmlscript/source/xmldlg_imexp/xmldlg_import.cxx |   17 ++---------
 2 files changed, 9 insertions(+), 43 deletions(-)

New commits:
commit d812281f96b03866c5d367380409c266b9bb8d05
Author: Jelle van der Waa <jelle at vdwaa.nl>
Date:   Mon Aug 12 22:11:38 2013 +0200

    fdo#57950: Remove some chained appends in xmlscript
    
    Change-Id: I7061f59077a75b879ad42179b839894747f5ba5b
    Reviewed-on: https://gerrit.libreoffice.org/5377
    Reviewed-by: Tor Lillqvist <tml at iki.fi>
    Tested-by: Tor Lillqvist <tml at iki.fi>

diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx
index 450d18e..0f7c5b0 100644
--- a/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx
+++ b/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx
@@ -80,41 +80,25 @@ Reference< xml::sax::XAttributeList > Style::createElement()
     // background-color
     if (_set & 0x1)
     {
-        OUStringBuffer buf( 16 );
-        buf.append( (sal_Unicode)'0' );
-        buf.append( (sal_Unicode)'x' );
-        buf.append( OUString::valueOf( (sal_Int64)(sal_uInt64)_backgroundColor, 16 ) );
-        pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":background-color", buf.makeStringAndClear() );
+        pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":background-color", "0x" + OUString::number(_backgroundColor,16));
     }
 
     // text-color
     if (_set & 0x2)
     {
-        OUStringBuffer buf( 16 );
-        buf.append( (sal_Unicode)'0' );
-        buf.append( (sal_Unicode)'x' );
-        buf.append( OUString::valueOf( (sal_Int64)(sal_uInt64)_textColor, 16 ) );
-        pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":text-color", buf.makeStringAndClear() );
+        pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":text-color", "0x" + OUString::number(_textColor,16));
     }
 
     // textline-color
     if (_set & 0x20)
     {
-        OUStringBuffer buf( 16 );
-        buf.append( (sal_Unicode)'0' );
-        buf.append( (sal_Unicode)'x' );
-        buf.append( OUString::valueOf( (sal_Int64)(sal_uInt64)_textLineColor, 16 ) );
-        pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":textline-color", buf.makeStringAndClear() );
+        pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":textline-color", "0x" + OUString::number(_textLineColor,16));
     }
 
     // fill-color
     if (_set & 0x10)
     {
-        OUStringBuffer buf( 16 );
-        buf.append( (sal_Unicode)'0' );
-        buf.append( (sal_Unicode)'x' );
-        buf.append( OUString::valueOf( (sal_Int64)(sal_uInt64)_fillColor, 16 ) );
-        pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":fill-color", buf.makeStringAndClear() );
+        pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":fill-color", "0x" + OUString::number(_fillColor,16));
     }
 
     // border
@@ -132,10 +116,7 @@ Reference< xml::sax::XAttributeList > Style::createElement()
             pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":border", "simple" );
             break;
         case BORDER_SIMPLE_COLOR: {
-            OUStringBuffer buf;
-            buf.appendAscii( "0x" );
-            buf.append( OUString::valueOf((sal_Int64)(sal_uInt64)_borderColor, 16 ) );
-            pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":border", buf.makeStringAndClear() );
+            pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":border", "0x" + OUString::number(_borderColor,16));
             break;
         }
         default:
@@ -535,11 +516,7 @@ void ElementDescriptor::readHexLongAttr( OUString const & rPropName, OUString co
         Any a( _xProps->getPropertyValue( rPropName ) );
         if (a.getValueTypeClass() == TypeClass_LONG)
         {
-            OUStringBuffer buf( 16 );
-            buf.append( (sal_Unicode)'0' );
-            buf.append( (sal_Unicode)'x' );
-            buf.append( OUString::valueOf( (sal_Int64)(sal_uInt64)*(sal_uInt32 *)a.getValue(), 16 ) );
-            addAttribute( rAttrName, buf.makeStringAndClear() );
+            addAttribute( rAttrName, "0x" + OUString::number((sal_Int64)(sal_uInt64)*(sal_uInt32 *)a.getValue(),16)  );
         }
     }
 }
diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx
index b05ea5b..ef41489 100644
--- a/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx
+++ b/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx
@@ -1444,11 +1444,7 @@ void ImportContext::importEvents(
                         if (getStringAttr( &aLocation, "location", xAttributes, _pImport->XMLNS_SCRIPT_UID ))
                         {
                             // prepend location
-                            OUStringBuffer buf;
-                            buf.append( aLocation );
-                            buf.append( (sal_Unicode)':' );
-                            buf.append( descr.ScriptCode );
-                            descr.ScriptCode = buf.makeStringAndClear();
+                            descr.ScriptCode = aLocation + ":" + descr.ScriptCode;
                         }
                     }
                     else if ( descr.ScriptType == "Script" )
@@ -1458,10 +1454,7 @@ void ImportContext::importEvents(
                         // the protocol ) and fix it up!!
                         if ( descr.ScriptCode.indexOf( ':' ) == -1 )
                         {
-                            OUStringBuffer buf;
-                            buf.append( "vnd.sun.star.script:" );
-                            buf.append( descr.ScriptCode );
-                            descr.ScriptCode = buf.makeStringAndClear();
+                            descr.ScriptCode = "vnd.sun.start.script:" + descr.ScriptCode;
                         }
                     }
 
@@ -1525,11 +1518,7 @@ void ImportContext::importEvents(
                     getStringAttr( &descr.AddListenerParam, "param", xAttributes, _pImport->XMLNS_DIALOGS_UID );
                 }
 
-                OUStringBuffer buf;
-                buf.append( descr.ListenerType );
-                buf.appendAscii( "::" );
-                buf.append( descr.EventMethod );
-                xEvents->insertByName( buf.makeStringAndClear(), makeAny( descr ) );
+                xEvents->insertByName( descr.ListenerType + "::" + descr.EventMethod, makeAny( descr ) );
             }
         }
     }


More information about the Libreoffice-commits mailing list