[ooo-build-commit] .: patches/dev300

Kohei Yoshida kohei at kemper.freedesktop.org
Fri Apr 9 11:58:07 PDT 2010


 patches/dev300/apply                         |    3 
 patches/dev300/calc-formula-r1c1-ui-fix.diff |  194 +++++++++++++++++++++++++++
 2 files changed, 197 insertions(+)

New commits:
commit e644f379e2474da356bc1fa4c623166ec14b47be
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Fri Apr 9 14:55:00 2010 -0400

    Fixed two UI issues in Excel R1C1 formula syntax mode.
    
    * patches/dev300/apply:
    * patches/dev300/calc-formula-r1c1-ui-fix.diff: Fixed autosum in R1C1
      mode, which previously still produced A1-style reference string.
      Also, selecting references from the formula wizard was not exactly
      working in R1C1 mode due to the difference in R1C1-style relative
      reference which always is relative to the current cell.  That's
      now fixed too. (n#595078, n#595080)

diff --git a/patches/dev300/apply b/patches/dev300/apply
index 93f6970..b845376 100644
--- a/patches/dev300/apply
+++ b/patches/dev300/apply
@@ -3786,6 +3786,9 @@ calc-last-used-function-opcode-fix.diff, kohei
 # Allow array result to be computed even when the auto calculate is off.
 calc-formula-matrix-no-autocalc.diff, n#503918, kohei
 
+# Fix auto-sum and reference selection for function wizard in R1C1 mode.
+calc-formula-r1c1-ui-fix.diff, n#595078, n#595080, kohei
+
 [ GentooExperimental ]
 SectionOwner => hmth
 # jemalloc, FreeBSD 7 allocator
diff --git a/patches/dev300/calc-formula-r1c1-ui-fix.diff b/patches/dev300/calc-formula-r1c1-ui-fix.diff
new file mode 100644
index 0000000..dd4d4e1
--- /dev/null
+++ b/patches/dev300/calc-formula-r1c1-ui-fix.diff
@@ -0,0 +1,194 @@
+diff --git sc/source/ui/app/inputwin.cxx sc/source/ui/app/inputwin.cxx
+index bc44878..7eba78c 100644
+--- sc/source/ui/app/inputwin.cxx
++++ sc/source/ui/app/inputwin.cxx
+@@ -398,8 +398,10 @@ void __EXPORT ScInputWindow::Select()
+                             const BOOL bDataFound = pViewSh->GetAutoSumArea( aRangeList );
+                             if ( bDataFound )
+                             {
++                                ScAddress aAddr = aRangeList.Last()->aEnd;
++                                aAddr.IncRow();
+                                 const sal_Bool bSubTotal( UseSubTotal( &aRangeList ) );
+-                                pViewSh->EnterAutoSum( aRangeList, bSubTotal );	// Block mit Summen fuellen
++                                pViewSh->EnterAutoSum( aRangeList, bSubTotal, aAddr );
+                             }
+                         }
+                         else
+@@ -415,7 +417,10 @@ void __EXPORT ScInputWindow::Select()
+                                     pViewSh->MarkRange( aRange, FALSE, FALSE );
+                                     pViewSh->SetCursor( aRange.aEnd.Col(), aRange.aEnd.Row() );
+                                     const ScRangeList aRangeList;
+-                                    const String aFormula = pViewSh->GetAutoSumFormula( aRangeList, bSubTotal );
++                                    ScAddress aAddr = aRange.aEnd;
++                                    aAddr.IncRow();
++                                    const String aFormula = pViewSh->GetAutoSumFormula(
++                                        aRangeList, bSubTotal, aAddr );
+                                     SetFuncString( aFormula );
+                                     break;
+                                 }
+@@ -427,7 +432,8 @@ void __EXPORT ScInputWindow::Select()
+                         ScRangeList aRangeList;
+                         const BOOL bDataFound = pViewSh->GetAutoSumArea( aRangeList );
+                         const sal_Bool bSubTotal( UseSubTotal( &aRangeList ) );
+-                        const String aFormula = pViewSh->GetAutoSumFormula( aRangeList, bSubTotal );
++                        ScAddress aAddr = pViewSh->GetViewData()->GetCurPos();
++                        const String aFormula = pViewSh->GetAutoSumFormula( aRangeList, bSubTotal, aAddr );
+                         SetFuncString( aFormula );
+ 
+                         if ( bDataFound && pScMod->IsEditMode() )
+diff --git sc/source/ui/formdlg/formula.cxx sc/source/ui/formdlg/formula.cxx
+index be4578f..8b68131 100644
+--- sc/source/ui/formdlg/formula.cxx
++++ sc/source/ui/formdlg/formula.cxx
+@@ -456,10 +456,15 @@ void ScFormulaDlg::SetReference( const ScRange& rRef, ScDocument* pRefDoc )
+         }
+         else
+         {
+-            USHORT nFmt = ( rRef.aStart.Tab() == aCursorPos.Tab() )
+-                                ? SCA_VALID
+-                                : SCA_VALID | SCA_TAB_3D;
+-            rRef.Format( aRefStr, nFmt, pRefDoc, pRefDoc->GetAddressConvention() );
++            ScTokenArray aArray;
++            ScComplexRefData aRefData;
++            aRefData.InitRangeRel(rRef, aCursorPos);
++            aArray.AddDoubleReference(aRefData);
++            ScCompiler aComp(pDoc, aCursorPos, aArray);
++            aComp.SetGrammar(pDoc->GetGrammar());
++            ::rtl::OUStringBuffer aBuf;
++            aComp.CreateStringFromTokenArray(aBuf);
++            aRefStr = aBuf.makeStringAndClear();
+         }
+ 
+         UpdateParaWin(theSel,aRefStr);
+diff --git sc/source/ui/inc/viewfunc.hxx sc/source/ui/inc/viewfunc.hxx
+index 7686540..f341621 100644
+--- sc/source/ui/inc/viewfunc.hxx
++++ sc/source/ui/inc/viewfunc.hxx
+@@ -96,9 +96,9 @@ public:
+     BYTE			GetSelectionScriptType();
+ 
+     BOOL			GetAutoSumArea(ScRangeList& rRangeList);
+-    void			EnterAutoSum(const ScRangeList& rRangeList, sal_Bool bSubTotal);
++    void			EnterAutoSum(const ScRangeList& rRangeList, bool bSubTotal, const ScAddress& rAddr);
+     bool            AutoSum( const ScRange& rRange, bool bSubTotal, bool bSetCursor, bool bContinue );
+-    String          GetAutoSumFormula( const ScRangeList& rRangeList, bool bSubTotal );
++    String          GetAutoSumFormula( const ScRangeList& rRangeList, bool bSubTotal, const ScAddress& rAddr );
+ 
+     void			EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rString,
+                                BOOL bRecord = TRUE, const EditTextObject* pData = NULL );
+diff --git sc/source/ui/view/viewfun2.cxx sc/source/ui/view/viewfun2.cxx
+index 9c0f929..0b244ad 100644
+--- sc/source/ui/view/viewfun2.cxx
++++ sc/source/ui/view/viewfun2.cxx
+@@ -97,6 +97,11 @@ using namespace com::sun::star;
+ 
+ #include "tabbgcolor.hxx" //DBW
+ 
++#include <boost/scoped_ptr.hpp>
++
++using ::rtl::OUStringBuffer;
++using ::rtl::OUString;
++
+ // helper func defined in docfunc.cxx
+ void VBA_DeleteModule( ScDocShell& rDocSh, String& sModuleName );
+ 
+@@ -510,9 +515,9 @@ BOOL ScViewFunc::GetAutoSumArea( ScRangeList& rRangeList )
+ 
+ //----------------------------------------------------------------------------
+ 
+-void ScViewFunc::EnterAutoSum(const ScRangeList& rRangeList, sal_Bool bSubTotal)		// Block mit Summen fuellen
++void ScViewFunc::EnterAutoSum(const ScRangeList& rRangeList, bool bSubTotal, const ScAddress& rAddr)
+ {
+-    String aFormula = GetAutoSumFormula( rRangeList, bSubTotal );
++    String aFormula = GetAutoSumFormula( rRangeList, bSubTotal, rAddr );
+     EnterBlock( aFormula, NULL );
+ }
+ 
+@@ -665,7 +670,8 @@ bool ScViewFunc::AutoSum( const ScRange& rRange, bool bSubTotal, bool bSetCursor
+                 const ScRange aRange( nCol, nStartRow, nTab, nCol, nSumEndRow, nTab );
+                 if ( lcl_GetAutoSumForColumnRange( pDoc, aRangeList, aRange ) )
+                 {
+-                    const String aFormula = GetAutoSumFormula( aRangeList, bSubTotal );
++                    const String aFormula = GetAutoSumFormula(
++                        aRangeList, bSubTotal, ScAddress(nCol, nInsRow, nTab));
+                     EnterData( nCol, nInsRow, nTab, aFormula );
+                 }
+             }
+@@ -698,7 +704,7 @@ bool ScViewFunc::AutoSum( const ScRange& rRange, bool bSubTotal, bool bSetCursor
+                 const ScRange aRange( nStartCol, nRow, nTab, nSumEndCol, nRow, nTab );
+                 if ( lcl_GetAutoSumForRowRange( pDoc, aRangeList, aRange ) )
+                 {
+-                    const String aFormula = GetAutoSumFormula( aRangeList, bSubTotal );
++                    const String aFormula = GetAutoSumFormula( aRangeList, bSubTotal, ScAddress(nInsCol, nRow, nTab) );
+                     EnterData( nInsCol, nRow, nTab, aFormula );
+                 }
+             }
+@@ -718,37 +724,42 @@ bool ScViewFunc::AutoSum( const ScRange& rRange, bool bSubTotal, bool bSetCursor
+ 
+ //----------------------------------------------------------------------------
+ 
+-String ScViewFunc::GetAutoSumFormula( const ScRangeList& rRangeList, bool bSubTotal )
++String ScViewFunc::GetAutoSumFormula( const ScRangeList& rRangeList, bool bSubTotal, const ScAddress& rAddr )
+ {
+-    String aFormula = '=';
+-    ScFunctionMgr* pFuncMgr = ScGlobal::GetStarCalcFunctionMgr();
+-    const ScFuncDesc* pDesc = NULL;
+-    if ( bSubTotal )
+-    {
+-        pDesc = pFuncMgr->Get( SC_OPCODE_SUB_TOTAL );
+-    }
+-    else
++    ScViewData* pViewData = GetViewData();
++    ScDocument* pDoc = pViewData->GetDocument();
++    ::boost::scoped_ptr<ScTokenArray> pArray(new ScTokenArray);
++
++    pArray->AddOpCode(bSubTotal ? ocSubTotal : ocSum);
++    pArray->AddOpCode(ocOpen);
++
++    if (bSubTotal)
+     {
+-        pDesc = pFuncMgr->Get( SC_OPCODE_SUM );
++        pArray->AddDouble(9);
++        pArray->AddOpCode(ocSep);
+     }
+-    if ( pDesc && pDesc->pFuncName )
++
++    ScRangeList aRangeList = rRangeList;
++    const ScRange* pFirst = aRangeList.First();
++    for (const ScRange* p = pFirst; p; p = aRangeList.Next())
+     {
+-        aFormula += *pDesc->pFuncName;
+-        if ( bSubTotal )
+-        {
+-            aFormula.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "(9;" ) );
+-        }
+-        else
+-        {
+-            aFormula += '(';
+-        }
+-        ScDocument* pDoc = GetViewData()->GetDocument();
+-        String aRef;
+-        rRangeList.Format( aRef, SCA_VALID, pDoc );
+-        aFormula += aRef;
+-        aFormula += ')';
++        if (p != pFirst)
++            pArray->AddOpCode(ocSep);
++        ScComplexRefData aRef;
++        aRef.InitRangeRel(*p, rAddr);
++        pArray->AddDoubleReference(aRef);
+     }
+-    return aFormula;
++
++    pArray->AddOpCode(ocClose);
++
++    ScCompiler aComp(pDoc, rAddr, *pArray);
++    aComp.SetGrammar(pDoc->GetGrammar());
++    OUStringBuffer aBuf;
++    aComp.CreateStringFromTokenArray(aBuf);
++    OUString aFormula = aBuf.makeStringAndClear();
++    aBuf.append(sal_Unicode('='));
++    aBuf.append(aFormula);
++    return aBuf.makeStringAndClear();
+ }
+ 
+ //----------------------------------------------------------------------------


More information about the ooo-build-commit mailing list