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

Matteo Casalin matteo.casalin at yahoo.com
Sun Oct 13 11:22:03 PDT 2013


 sw/inc/fesh.hxx                 |    2 +-
 sw/source/core/frmedt/fetab.cxx |   40 +++++++++++++++++-----------------------
 sw/source/ui/shells/tabsh.cxx   |    2 +-
 3 files changed, 19 insertions(+), 25 deletions(-)

New commits:
commit abbf6b217970bf176da552f958d974de64952e2e
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Oct 6 17:35:23 2013 +0200

    String to OUString
    
    Change-Id: Ie0cdb4288cee10bca9c7ea94ba3745748f4e080f

diff --git a/sw/inc/fesh.hxx b/sw/inc/fesh.hxx
index 0e80c84..ebd979b 100644
--- a/sw/inc/fesh.hxx
+++ b/sw/inc/fesh.hxx
@@ -684,7 +684,7 @@ public:
 
     sal_Bool SetColRowWidthHeight( sal_uInt16 eType, sal_uInt16 nDiff = 283 );
 
-    sal_Bool GetAutoSum( String& rFml ) const;
+    sal_Bool GetAutoSum( OUString& rFml ) const;
 
     /** Phy: real page count.
      Virt: consider offset that may have been set by user. */
diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx
index 08966bc..37da874 100644
--- a/sw/source/core/frmedt/fetab.cxx
+++ b/sw/source/core/frmedt/fetab.cxx
@@ -2346,19 +2346,18 @@ static bool lcl_IsFormulaSelBoxes( const SwTable& rTbl, const SwTblBoxFormula& r
 }
 
     // ask formula for auto-sum
-sal_Bool SwFEShell::GetAutoSum( String& rFml ) const
+sal_Bool SwFEShell::GetAutoSum( OUString& rFml ) const
 {
     SwFrm *pFrm = GetCurrFrm();
     SwTabFrm *pTab = pFrm ? pFrm->ImplFindTabFrm() : 0;
     if( !pTab )
         return sal_False;
 
-    rFml = OUString::createFromAscii( sCalc_Sum );
-
     SwCellFrms aCells;
+    OUString sFields;
     if( ::GetAutoSumSel( *this, aCells ))
     {
-        sal_uInt16 nW = 0, nInsPos = 0;
+        sal_uInt16 nW = 0;
         for( size_t n = aCells.size(); n; )
         {
             SwCellFrm* pCFrm = aCells[ --n ];
@@ -2371,9 +2370,6 @@ sal_Bool SwFEShell::GetAutoSum( String& rFml ) const
                 if( USHRT_MAX == nBoxW )
                     continue;       // skip space at beginning
 
-                rFml += '(';
-                nInsPos = rFml.Len();
-
                 // formula only if box is contained
                 if( RES_BOXATR_FORMULA == nBoxW &&
                     !::lcl_IsFormulaSelBoxes( *pTab->GetTable(), pCFrm->
@@ -2383,10 +2379,8 @@ sal_Bool SwFEShell::GetAutoSum( String& rFml ) const
                     // restore previous spaces!
                     for( size_t i = aCells.size(); n+1 < i; )
                     {
-                        String sTmp(OUString("|<"));
-                        sTmp += aCells[ --i ]->GetTabBox()->GetName();
-                        sTmp += '>';
-                        rFml.Insert( sTmp, nInsPos );
+                        sFields = "|<" + aCells[--i]->GetTabBox()->GetName() + ">"
+                            + sFields;
                     }
                 }
                 else
@@ -2400,7 +2394,7 @@ sal_Bool SwFEShell::GetAutoSum( String& rFml ) const
                         GetTabBox()->GetFrmFmt()->GetTblBoxFormula(), aCells ))
                     break;
                 else if( USHRT_MAX != nBoxW )
-                    rFml.Insert( cListDelim, nInsPos );
+                    sFields = OUString(cListDelim) + sFields;
                 else
                     break;
             }
@@ -2416,18 +2410,16 @@ sal_Bool SwFEShell::GetAutoSum( String& rFml ) const
                         // redo only for values!
 
                         nW = RES_BOXATR_VALUE;
-                        rFml.Erase( nInsPos );
+                        sFields = OUString();
                         // restore previous spaces!
                         for( size_t i = aCells.size(); n+1 < i; )
                         {
-                            String sTmp(OUString("|<" ));
-                            sTmp += aCells[ --i ]->GetTabBox()->GetName();
-                            sTmp += '>';
-                            rFml.Insert( sTmp, nInsPos );
+                            sFields = "|<" + aCells[--i]->GetTabBox()->GetName() + ">"
+                                + sFields;
                         }
                     }
                     else
-                        rFml.Insert( cListDelim, nInsPos );
+                        sFields = OUString(cListDelim) + sFields;
                 }
                 else if( USHRT_MAX == nBoxW )
                     break;
@@ -2439,14 +2431,16 @@ sal_Bool SwFEShell::GetAutoSum( String& rFml ) const
                 // possibly allow texts??
                 break;
 
-            rFml.Insert( "<" + OUString(pCFrm->GetTabBox()->GetName()) + ">", nInsPos );
-        }
-        if( nW )
-        {
-            rFml += ')';
+            sFields = "<" + pCFrm->GetTabBox()->GetName() + ">" + sFields;
         }
     }
 
+    rFml = OUString::createFromAscii( sCalc_Sum );
+    if (!sFields.isEmpty())
+    {
+        rFml += "(" + sFields + ")";
+    }
+
     return sal_True;
 }
 
diff --git a/sw/source/ui/shells/tabsh.cxx b/sw/source/ui/shells/tabsh.cxx
index 6b91fc7..68738b5 100644
--- a/sw/source/ui/shells/tabsh.cxx
+++ b/sw/source/ui/shells/tabsh.cxx
@@ -1018,7 +1018,7 @@ void SwTableShell::Execute(SfxRequest &rReq)
             const sal_uInt16 nId = SwInputChild::GetChildWindowId();
             SwInputChild* pChildWin = (SwInputChild*)pVFrame->
                                                 GetChildWindow( nId );
-            String sSum;
+            OUString sSum;
             GetShell().GetAutoSum(sSum);
             if( pChildWin )
                 pChildWin->SetFormula( sSum );


More information about the Libreoffice-commits mailing list