[ooo-build-commit] .: sc/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Mon Oct 4 11:53:54 PDT 2010
sc/source/ui/app/inputwin.cxx | 12 ++++--
sc/source/ui/formdlg/formula.cxx | 13 ++++---
sc/source/ui/inc/viewfunc.hxx | 4 +-
sc/source/ui/view/viewfun2.cxx | 71 ++++++++++++++++++++++-----------------
4 files changed, 61 insertions(+), 39 deletions(-)
New commits:
commit 445e3596a1c044fdee75e5438ebdcd859a0e3945
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Mon Oct 4 14:52:20 2010 -0400
Ported calc-formula-r1c1-ui-fix.diff from ooo-build.
This fixes incorrect display of cell addresses in the UI when the
formula syntax mode is Excel R1C1.
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 360528a..279afc3 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -395,8 +395,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
@@ -412,7 +414,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;
}
@@ -424,7 +429,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 a/sc/source/ui/formdlg/formula.cxx b/sc/source/ui/formdlg/formula.cxx
index a084737..fe7c63c 100644
--- a/sc/source/ui/formdlg/formula.cxx
+++ b/sc/source/ui/formdlg/formula.cxx
@@ -452,10 +452,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 a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx
index 8eaeba8..f60cb46 100644
--- a/sc/source/ui/inc/viewfunc.hxx
+++ b/sc/source/ui/inc/viewfunc.hxx
@@ -92,9 +92,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 a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index 3572b8e..f226a56 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -90,7 +90,12 @@
#include <basic/sbstar.hxx>
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/script/XLibraryContainer.hpp>
+
+#include <boost/scoped_ptr.hpp>
+
using namespace com::sun::star;
+using ::rtl::OUStringBuffer;
+using ::rtl::OUString;
// helper func defined in docfunc.cxx
void VBA_DeleteModule( ScDocShell& rDocSh, String& sModuleName );
@@ -505,9 +510,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 );
}
@@ -660,7 +665,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 );
}
}
@@ -693,7 +699,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 );
}
}
@@ -713,37 +719,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