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

Matteo Casalin matteo.casalin at yahoo.com
Mon Sep 9 01:56:46 PDT 2013


 sw/source/filter/inc/msfilter.hxx       |    2 +-
 sw/source/filter/ww8/writerwordglue.cxx |   21 +++++++++++++--------
 sw/source/filter/ww8/wrtww8.hxx         |    2 +-
 sw/source/filter/ww8/ww8atr.cxx         |   24 +++++++++---------------
 4 files changed, 24 insertions(+), 25 deletions(-)

New commits:
commit ff4f2a414a4dcf8267a44f5463d07e4f0bbe0858
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Sep 8 17:44:41 2013 +0200

    String to OUstring
    
    Change-Id: I98f2e16f1e679cb2c01984ed34dc4efb254c918d
    Reviewed-on: https://gerrit.libreoffice.org/5876
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/source/filter/inc/msfilter.hxx b/sw/source/filter/inc/msfilter.hxx
index 5fbc954..37691ca 100644
--- a/sw/source/filter/inc/msfilter.hxx
+++ b/sw/source/filter/inc/msfilter.hxx
@@ -123,7 +123,7 @@ namespace sw
             @author
                 <a href="mailto:mmaher at openoffice.org">Martin Maher</a
         */
-        void SwapQuotesInField(String &rFmt);
+        void SwapQuotesInField(OUString &rFmt);
 
     }
 
diff --git a/sw/source/filter/ww8/writerwordglue.cxx b/sw/source/filter/ww8/writerwordglue.cxx
index 226b20c..d30e519 100644
--- a/sw/source/filter/ww8/writerwordglue.cxx
+++ b/sw/source/filter/ww8/writerwordglue.cxx
@@ -755,7 +755,9 @@ namespace sw
             short  nType = NUMBERFORMAT_DEFINED;
             sal_uInt32  nKey = 0;
 
-            SwapQuotesInField(rParams);
+            OUString sParams(rParams);
+            SwapQuotesInField(sParams);
+            rParams = sParams;
 
             // Force to Japanese when finding one of 'geaE'
             OUString sJChars( "geE" );
@@ -1016,16 +1018,19 @@ namespace sw
                 );
         }
 
-        void SwapQuotesInField(String &rFmt)
+        void SwapQuotesInField(OUString &rFmt)
         {
             //Swap unescaped " and ' with ' and "
-            xub_StrLen nLen = rFmt.Len();
-            for (xub_StrLen nI = 0; nI < nLen; ++nI)
+            const sal_Int32 nLen = rFmt.getLength();
+            for (sal_Int32 nI = 0; nI < nLen; ++nI)
             {
-                if ((rFmt.GetChar(nI) == '\"') && (!nI || rFmt.GetChar(nI-1) != '\\'))
-                    rFmt.SetChar(nI, '\'');
-                else if ((rFmt.GetChar(nI) == '\'') && (!nI || rFmt.GetChar(nI-1) != '\\'))
-                    rFmt.SetChar(nI, '\"');
+                if (!nI || rFmt[nI-1]!='\\')
+                {
+                    if (rFmt[nI]=='\"')
+                        rFmt = rFmt.replaceAt(nI, 1, "\'");
+                    else if (rFmt[nI]=='\'')
+                        rFmt = rFmt.replaceAt(nI, 1, "\"");
+                }
             }
         }
 
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index 7bef91d..5ae203f 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -741,7 +741,7 @@ public:
     static bool NoPageBreakSection( const SfxItemSet *pSet );
 
     // Compute the number format for WW dates
-    bool GetNumberFmt(const SwField& rFld, String& rStr);
+    bool GetNumberFmt(const SwField& rFld, OUString& rStr);
 
     virtual sal_uLong ReplaceCr( sal_uInt8 nChar ) = 0;
 
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 7b25c60..c0a34c8 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -2325,7 +2325,7 @@ void AttributeOutputBase::EndTOX( const SwSection& rSect )
     GetExport( ).bInWriteTOX = false;
 }
 
-bool MSWordExportBase::GetNumberFmt(const SwField& rFld, String& rStr)
+bool MSWordExportBase::GetNumberFmt(const SwField& rFld, OUString& rStr)
 {
     // Returns a date or time format string by using the US NfKeywordTable
     bool bHasFmt = false;
@@ -2338,16 +2338,14 @@ bool MSWordExportBase::GetNumberFmt(const SwField& rFld, String& rStr)
         LocaleDataWrapper aLocDat(pNFmtr->GetComponentContext(),
                                   LanguageTag(nLng));
 
-        String sFmt(pNumFmt->GetMappedFormatstring(GetNfKeywordTable(),
+        OUString sFmt(pNumFmt->GetMappedFormatstring(GetNfKeywordTable(),
             aLocDat));
 
-        if (sFmt.Len())
+        if (!sFmt.isEmpty())
         {
             sw::ms::SwapQuotesInField(sFmt);
 
-            rStr.AppendAscii( "\\@\"" );
-            rStr += sFmt;
-            rStr.AppendAscii( "\" " );
+            rStr = "\\@\"" + sFmt + "\" " ;
             bHasFmt = true;
         }
     }
@@ -2632,7 +2630,7 @@ void AttributeOutputBase::TextField( const SwFmtFld& rField )
             bWriteExpand = true;
         else
         {
-            String sStr;
+            OUString sStr;
             ww::eField eFld(ww::eNONE);
             switch (0xff & nSubType)
             {
@@ -2690,9 +2688,7 @@ void AttributeOutputBase::TextField( const SwFmtFld& rField )
                             if (nIndex != sFieldname.Len())
                                 sFieldname = sFieldname.Copy(nIndex + 1);
 
-                            sStr.Insert(sQuotes);
-                            sStr.Insert(sFieldname);
-                            sStr.Insert(sQuotes);
+                            sStr = sQuotes + sFieldname + sQuotes;
                         }
                     }
                     break;
@@ -2702,8 +2698,7 @@ void AttributeOutputBase::TextField( const SwFmtFld& rField )
 
             if (eFld != ww::eNONE)
             {
-                sStr.Insert(FieldString(eFld), 0);
-                GetExport().OutputField(pFld, eFld, sStr);
+                GetExport().OutputField(pFld, eFld, FieldString(eFld) + sStr);
             }
             else
                 bWriteExpand = true;
@@ -2711,14 +2706,13 @@ void AttributeOutputBase::TextField( const SwFmtFld& rField )
         break;
     case RES_DATETIMEFLD:
         {
-            String sStr;
+            OUString sStr;
             if (FIXEDFLD & nSubType || !GetExport().GetNumberFmt(*pFld, sStr))
                 bWriteExpand = true;
             else
             {
                 ww::eField eFld = (DATEFLD & nSubType) ? ww::eDATE : ww::eTIME;
-                sStr.Insert(FieldString(eFld), 0);
-                GetExport().OutputField(pFld, eFld, sStr);
+                GetExport().OutputField(pFld, eFld, FieldString(eFld) + sStr);
             }
         }
         break;


More information about the Libreoffice-commits mailing list