[Libreoffice-commits] core.git: Branch 'feature/unitver' - include/formula sc/inc sc/source

2016-01-05 Thread Benjamin Ni
 include/formula/token.hxx  |1 -
 sc/inc/formulacell.hxx |1 +
 sc/inc/units.hxx   |1 -
 sc/source/core/tool/interpr4.cxx   |3 +++
 sc/source/core/units/unitsimpl.cxx |4 ++--
 sc/source/core/units/unitsimpl.hxx |1 +
 6 files changed, 7 insertions(+), 4 deletions(-)

New commits:
commit 375d0cd087f8a2d76f8682109e585ff0e0837198
Author: Benjamin Ni <benjaminn...@hotmail.com>
Date:   Wed Jul 22 15:49:23 2015 +0100

cosmetic changes

Change-Id: I6826a23655c9556dac2be49a8f28d67e95e91ff2
Reviewed-on: https://gerrit.libreoffice.org/17582
Reviewed-by: Markus Mohrhard <markus.mohrh...@googlemail.com>
Tested-by: Markus Mohrhard <markus.mohrh...@googlemail.com>

diff --git a/include/formula/token.hxx b/include/formula/token.hxx
index 23d9787..9bb39b1 100644
--- a/include/formula/token.hxx
+++ b/include/formula/token.hxx
@@ -103,7 +103,6 @@ protected:
 public:
 FormulaToken( StackVar eTypeP,OpCode e = ocPush );
 FormulaToken( const FormulaToken& r );
-
 virtual ~FormulaToken();
 
 inline  voidDelete(){ delete this; }
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index 724b1e2..ff110fb 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -31,6 +31,7 @@
 #include 
 
 #include "types.hxx"
+#include "units.hxx"
 
 #include "formularesult.hxx"
 
diff --git a/sc/inc/units.hxx b/sc/inc/units.hxx
index 1e0c5ea..e93d745 100644
--- a/sc/inc/units.hxx
+++ b/sc/inc/units.hxx
@@ -58,7 +58,6 @@ public:
 static ::boost::shared_ptr< Units > GetUnits();
 
 virtual FormulaStatus verifyFormula(ScTokenArray* pArray, const ScAddress& 
rFormulaAddress, ScDocument* pDoc) = 0;
-
 /*
  * Split the input into value and unit, where rInput == rValue + rUnit.
  * (We assume that the unit is always the last part of the input string.)
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index bd84fa6..fe93ec0 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -65,6 +65,9 @@
 #include "doubleref.hxx"
 #include "queryparam.hxx"
 #include "tokenarray.hxx"
+#include "units.hxx"
+#include "scmod.hxx"
+#include "viewfunc.hxx"
 
 #include 
 #include 
diff --git a/sc/source/core/units/unitsimpl.cxx 
b/sc/source/core/units/unitsimpl.cxx
index 0c89201..f2101c2 100644
--- a/sc/source/core/units/unitsimpl.cxx
+++ b/sc/source/core/units/unitsimpl.cxx
@@ -526,11 +526,11 @@ HeaderUnitDescriptor 
UnitsImpl::findHeaderUnitForCell(const ScAddress& rCellAddr
 return { false, UtUnit(), boost::optional< ScAddress >(), OUString(""), -1 
};
 }
 
-FormulaStatus UnitsImpl::verifyFormula(ScTokenArray* pArray, const ScAddress& 
rFormulaAddress, ScDocument* pDoc) {
+FormulaStatus UnitsImpl::verifyFormula(ScTokenArray* pArray, const ScAddress& 
rFormulaAddress, ScDocument* pDoc)
+{
 #if DEBUG_FORMULA_COMPILER
 pArray->Dump();
 #endif
-
 stack< RAUSItem > aStack;
 
 for (FormulaToken* pToken = pArray->FirstRPN(); pToken != 0; pToken = 
pArray->NextRPN()) {
diff --git a/sc/source/core/units/unitsimpl.hxx 
b/sc/source/core/units/unitsimpl.hxx
index f3e2cb8..5bdee2a 100644
--- a/sc/source/core/units/unitsimpl.hxx
+++ b/sc/source/core/units/unitsimpl.hxx
@@ -137,6 +137,7 @@ private:
 HeaderUnitDescriptor extractUnitFromHeaderString(const OUString& rHeader);
 
 static OUString extractUnitStringFromFormat(const OUString& rFormatString);
+
 static OUString extractUnitStringForCell(const ScAddress& rAddress, 
ScDocument* pDoc);
 
 /**
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2016-01-05 Thread Benjamin Ni
 sc/inc/conditio.hxx |2 +
 sc/qa/unit/ucalc.cxx|   26 +
 sc/qa/unit/ucalc.hxx|2 +
 sc/source/core/data/validat.cxx |   49 +++-
 4 files changed, 78 insertions(+), 1 deletion(-)

New commits:
commit c01bcbc88522c5f86820105a45e2e5593ae01501
Author: Benjamin Ni <benjaminn...@hotmail.com>
Date:   Sun Jun 7 16:21:54 2015 +0100

Time wraparound validation feature

Change-Id: I49305167b1062dbe8158fdb446859138ba283da2
Reviewed-on: https://gerrit.libreoffice.org/16136
Tested-by: Jenkins <c...@libreoffice.org>
Tested-by: jan iversen <j...@documentfoundation.org>
Reviewed-by: jan iversen <j...@documentfoundation.org>

diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx
index d33ecc6..69f8ddd 100644
--- a/sc/inc/conditio.hxx
+++ b/sc/inc/conditio.hxx
@@ -154,10 +154,12 @@ public:
 class SC_DLLPUBLIC ScConditionEntry : public ScFormatEntry
 {
 // stored data:
+protected:
 ScConditionMode eOp;
 sal_uInt16  nOptions;
 double  nVal1;  // input or calculated
 double  nVal2;
+private:
 OUString  aStrVal1;   // input or calculated
 OUString  aStrVal2;
 OUString  aStrNmsp1;  // namespace to be used on 
(re)compilation, e.g. in XML import
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index ccb3619..7d836b1 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -45,6 +45,7 @@
 #include "interpre.hxx"
 #include "columniterator.hxx"
 #include "types.hxx"
+#include "validat.hxx"
 #include "conditio.hxx"
 #include "colorscale.hxx"
 #include "fillinfo.hxx"
@@ -5690,6 +5691,31 @@ void Test::testCondFormatInsertRow()
 m_pDoc->DeleteTab(0);
 }
 
+void Test::testValidity()
+{
+m_pDoc->InsertTab(0, "Test");
+
+m_pDoc->SetValue( 0, 0, 0, 22.0/24.0 );
+m_pDoc->SetValue( 2, 0, 0, 23.0/24.0 );
+m_pDoc->SetValue( 4, 0, 0, 24.0/24.0 );
+
+// invalid between 2300-0100 hrs
+ScValidationData* pData0 = new ScValidationData( SC_VALID_TIME, 
SC_COND_NOTBETWEEN,
+OUString::number(23.0/24.0), OUString::number(1.0/24.0), m_pDoc, 
ScAddress(0,0,0) );
+ScValidationData* pData1 = new ScValidationData( SC_VALID_TIME, 
SC_COND_NOTBETWEEN,
+OUString::number(23.0/24.0), OUString::number(1.0/24.0), m_pDoc, 
ScAddress(2,0,0) );
+ScValidationData* pData2 = new ScValidationData( SC_VALID_TIME, 
SC_COND_NOTBETWEEN,
+OUString::number(23.0/24.0), OUString::number(1.0/24.0), m_pDoc, 
ScAddress(4,0,0) );
+
+ScRefCellValue aCell;
+aCell.assign(*m_pDoc, ScAddress(0,0,0));
+CPPUNIT_ASSERT(  pData0->IsDataValid( aCell, ScAddress(0,0,0) ) );
+aCell.assign(*m_pDoc, ScAddress(2,0,0));
+CPPUNIT_ASSERT( !pData1->IsDataValid( aCell, ScAddress(2,0,0) ) );
+aCell.assign(*m_pDoc, ScAddress(4,0,0));
+CPPUNIT_ASSERT( !pData2->IsDataValid( aCell, ScAddress(4,0,0) ) );
+}
+
 void Test::testCondFormatInsertDeleteSheets()
 {
 m_pDoc->InsertTab(0, "Test");
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index b3e5bf3..6085311 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -433,6 +433,7 @@ public:
 void testCondFormatINSDEL();
 void testCondFormatInsertRow();
 void testCondFormatInsertCol();
+void testValidity();
 void testCondFormatInsertDeleteSheets();
 void testCondCopyPaste();
 void testCondCopyPasteSingleCell(); //e.g. fdo#82503
@@ -669,6 +670,7 @@ public:
 CPPUNIT_TEST(testCondFormatINSDEL);
 CPPUNIT_TEST(testCondFormatInsertRow);
 CPPUNIT_TEST(testCondFormatInsertCol);
+CPPUNIT_TEST(testValidity);
 CPPUNIT_TEST(testCondFormatInsertDeleteSheets);
 CPPUNIT_TEST(testCondCopyPaste);
 CPPUNIT_TEST(testCondCopyPasteSingleCell);
diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx
index 437434a..c4c4ba6 100644
--- a/sc/source/core/data/validat.cxx
+++ b/sc/source/core/data/validat.cxx
@@ -543,7 +543,54 @@ bool ScValidationData::IsDataValid( ScRefCellValue& rCell, 
const ScAddress& rPos
 OSL_FAIL("not yet done");
 break;
 }
-
+if (eDataMode == SC_VALID_TIME) {
+// consider only time portion (i.e. decimal)
+double nComp1 = (nVal1 - floor(nVal1));
+double nComp2 = (nVal2 - floor(nVal2));
+double nInVal = (nVal  - floor(nVal ));
+switch (eOp)
+{
+case SC_COND_NONE:
+break;  // Always sal_False
+case SC_COND_EQUAL:
+bOk = ::rtl::math::approxEqual( nInVal, nComp1 );
+break;
+case SC_COND_NOTEQUAL:
+bOk = !::rtl::math::approxEqual( nInVal, nComp1 );
+ 

[Libreoffice-commits] core.git: basic/qa basic/source binaryurp/source bridges/test chart2/qa chart2/source cli_ure/source codemaker/source compilerplugins/clang configmgr/source connectivity/source c

2015-11-02 Thread Benjamin Ni
 basic/qa/cppunit/basic_coverage.cxx   |6 
 basic/source/classes/sbunoobj.cxx |   16 -
 basic/source/comp/exprnode.cxx|   20 -
 basic/source/runtime/methods1.cxx |6 
 basic/source/runtime/runtime.cxx  |6 
 binaryurp/source/bridge.cxx   |   26 +-
 binaryurp/source/proxy.cxx|   10 
 binaryurp/source/reader.cxx   |   14 -
 binaryurp/source/unmarshal.cxx|6 
 binaryurp/source/writer.cxx   |   10 
 bridges/test/java_uno/acquire/testacquire.cxx |6 
 chart2/qa/extras/chart2export.cxx |   20 -
 chart2/qa/extras/chart2import.cxx |6 
 chart2/source/controller/dialogs/ObjectNameProvider.cxx   |8 
 chart2/source/view/charttypes/VSeriesPlotter.cxx  |8 
 cli_ure/source/climaker/climaker_app.cxx  |   16 -
 codemaker/source/codemaker/exceptiontree.cxx  |6 
 codemaker/source/codemaker/global.cxx |   12 -
 codemaker/source/cppumaker/cpputype.cxx   |   72 
+++---
 codemaker/source/cppumaker/dumputils.cxx  |   24 +-
 codemaker/source/javamaker/javatype.cxx   |   12 -
 compilerplugins/clang/implicitboolconversion.cxx  |  110 
+-
 compilerplugins/clang/literaltoboolconversion.cxx |8 
 compilerplugins/clang/plugin.cxx  |   14 -
 compilerplugins/clang/pluginhandler.cxx   |   18 -
 compilerplugins/clang/store/constantfunction.cxx  |6 
 compilerplugins/clang/stringconstant.cxx  |   24 +-
 compilerplugins/clang/vclwidgets.cxx  |   24 +-
 configmgr/source/childaccess.cxx  |8 
 configmgr/source/components.cxx   |6 
 configmgr/source/partial.cxx  |6 
 connectivity/source/commontools/dbmetadata.cxx|   14 -
 connectivity/source/drivers/mork/MQueryHelper.cxx |6 
 connectivity/source/drivers/mork/MorkParser.cxx   |6 
 connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.cxx |3 
 connectivity/source/drivers/odbc/OPreparedStatement.cxx   |   10 
 connectivity/source/drivers/postgresql/pq_statement.cxx   |6 
 cppu/source/AffineBridge/AffineBridge.cxx |6 
 cppuhelper/source/propertysetmixin.cxx|   12 -
 dbaccess/source/core/api/KeySet.cxx   |   12 -
 desktop/source/deployment/misc/dp_update.cxx  |   24 +-
 editeng/source/misc/svxacorr.cxx  |   26 +-
 i18npool/source/breakiterator/breakiterator_unicode.cxx   |6 
 i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx |   20 -
 i18npool/source/nativenumber/nativenumbersupplier.cxx |   34 
+--
 45 files changed, 358 insertions(+), 361 deletions(-)

New commits:
commit be729e772196f33543e21cb9bac21add87726b20
Author: Benjamin Ni <benjaminn...@hotmail.com>
Date:   Fri Sep 25 11:41:53 2015 +0100

tdf#94269: Replace "n" prefix for bool variables with "b"

Change-Id: I178545792c7354a362658ac7ef8b1d4cf0865797
Signed-off-by: Michael Stahl <mst...@redhat.com>

diff --git a/basic/qa/cppunit/basic_coverage.cxx 
b/basic/qa/cppunit/basic_coverage.cxx
index 1c4cb3a..8e321c7 100644
--- a/basic/qa/cppunit/basic_coverage.cxx
+++ b/basic/qa/cppunit/basic_coverage.cxx
@@ -73,7 +73,7 @@ void Coverage::test_success()
 void Coverage::run_test(const OUString& sFileURL)
 {
 m_sCurrentTest = sFileURL;
-bool result = false;
+bool bResult = false;
 MacroSnippet testMacro;
 testMacro.LoadSourceFromFile( sFileURL );
 testMacro.Compile();
@@ -82,10 +82,10 @@ void Coverage::run_test(const OUString& sFileURL)
 SbxVariableRef pResult = testMacro.Run();
 if( pResult && pResult->GetInteger() == 1 )
 {
-result = true;
+bResult = true;
 }
 }
-if(result)
+if(bResult)
 {
 test_success();
 }
diff --git a/basic/source/classes/sbunoobj.cxx 
b/basic/source/classes/sbunoobj.cxx
index a522472..3f64566 100644
--- a/basic/sou

[Libreoffice-commits] core.git: 3 commits - formula/source sc/inc sc/qa sc/source

2015-07-27 Thread Benjamin Ni
 formula/source/ui/dlg/formula.cxx |   50 +++---
 formula/source/ui/dlg/structpg.hxx|2 +
 sc/inc/simpleformulacalc.hxx  |3 +
 sc/qa/unit/ucalc.cxx  |   29 +
 sc/source/core/data/simpleformulacalc.cxx |   23 +
 sc/source/ui/formdlg/formula.cxx  |2 +
 6 files changed, 92 insertions(+), 17 deletions(-)

New commits:
commit 774085dbe5c332f2be757f5f6a0324280dd72651
Author: Benjamin Ni benjaminn...@hotmail.com
Date:   Mon Jul 27 19:59:28 2015 +0200

tdf#92548, limit number of characters shown in formula wizard

Change-Id: I5c322140d40e1ec31e8664a6f731e57b9b3defdb

diff --git a/formula/source/ui/dlg/formula.cxx 
b/formula/source/ui/dlg/formula.cxx
index 90dfb5b..7399e06 100644
--- a/formula/source/ui/dlg/formula.cxx
+++ b/formula/source/ui/dlg/formula.cxx
@@ -723,7 +723,7 @@ void FormulaDlg_Impl::MakeTree(IStructHelper* 
_pTree,SvTreeListEntry* pParent,Fo
 const IFunctionDescription* pDesc 
=pFuncPage-GetFuncDesc( pFuncPage-GetFunction() );
 if(pDesc==pFuncDesc || !pFuncPage-IsVisible())
 {
-// EditNextFunc(false);
+EditNextFunc(false);
 }
 }
 
diff --git a/sc/inc/simpleformulacalc.hxx b/sc/inc/simpleformulacalc.hxx
index 2d20f6d..f12e261 100644
--- a/sc/inc/simpleformulacalc.hxx
+++ b/sc/inc/simpleformulacalc.hxx
@@ -33,6 +33,7 @@ private:
 formula::FormulaGrammar::Grammar maGram;
 bool bIsMatrix;
 OUString maMatrixFormulaResult;
+bool mbLimitString;
 
 public:
 ScSimpleFormulaCalculator(ScDocument* pDoc, const ScAddress rAddr,
@@ -50,6 +51,8 @@ public:
 bool HasColRowName();
 
 ScTokenArray* GetCode();
+
+void SetLimitString(bool bLimitString);
 };
 
 #endif
diff --git a/sc/source/core/data/simpleformulacalc.cxx 
b/sc/source/core/data/simpleformulacalc.cxx
index d359667..a931551 100644
--- a/sc/source/core/data/simpleformulacalc.cxx
+++ b/sc/source/core/data/simpleformulacalc.cxx
@@ -13,6 +13,8 @@
 #include interpre.hxx
 #include compiler.hxx
 
+#define DISPLAY_LEN 15
+
 ScSimpleFormulaCalculator::ScSimpleFormulaCalculator( ScDocument* pDoc, const 
ScAddress rAddr,
 const OUString rFormula, formula::FormulaGrammar::Grammar eGram )
 : mnFormatType(0)
@@ -22,6 +24,7 @@ ScSimpleFormulaCalculator::ScSimpleFormulaCalculator( 
ScDocument* pDoc, const Sc
 , mpDoc(pDoc)
 , maGram(eGram)
 , bIsMatrix(false)
+, mbLimitString(false)
 {
 // compile already here
 ScCompiler aComp(mpDoc, maAddr);
@@ -53,6 +56,21 @@ void ScSimpleFormulaCalculator::Calculate()
 aComp.CreateStringFromToken(aStr, aInt.GetResultToken().get(), false);
 
 bIsMatrix = true;
+
+if (mbLimitString)
+{
+size_t n = aStr.getLength();
+for (size_t i = DISPLAY_LEN; i  n; ++i)
+{
+if (aStr[i] == ',' || aStr[i] == ';')
+{
+aStr.truncate(i);
+aStr.append(...);
+break;
+}
+}
+}
+
 maMatrixFormulaResult = aStr.makeStringAndClear();
 }
 mnFormatType = aInt.GetRetFormatType();
@@ -121,4 +139,9 @@ ScTokenArray* ScSimpleFormulaCalculator::GetCode()
 return mpCode.get();
 }
 
+void ScSimpleFormulaCalculator::SetLimitString(bool bLimitString)
+{
+mbLimitString = bLimitString;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/formdlg/formula.cxx b/sc/source/ui/formdlg/formula.cxx
index 4160619..d6c1b17 100644
--- a/sc/source/ui/formdlg/formula.cxx
+++ b/sc/source/ui/formdlg/formula.cxx
@@ -308,6 +308,7 @@ bool ScFormulaDlg::Close()
 bool ScFormulaDlg::calculateValue( const OUString rStrExp, OUString 
rStrResult )
 {
 boost::scoped_ptrScSimpleFormulaCalculator pFCell( new 
ScSimpleFormulaCalculator( pDoc, aCursorPos, rStrExp ) );
+pFCell-SetLimitString(true);
 
 // HACK! to avoid neither #REF! from ColRowNames
 // if a name is added as actually range in the overall formula,
@@ -324,6 +325,7 @@ bool ScFormulaDlg::calculateValue( const OUString rStrExp, 
OUString rStrResult
 aBraced.append(rStrExp);
 aBraced.append(')');
 pFCell.reset( new ScSimpleFormulaCalculator( pDoc, aCursorPos, 
aBraced.makeStringAndClear() ) );
+pFCell-SetLimitString(true);
 }
 else
 bColRowName = false;
commit f82d89f35207fc1cfc00ad5cd914b74c55c3e3d2
Author: Benjamin Ni benjaminn...@hotmail.com
Date:   Sun Jul 12 15:41:55 2015 +0100

tdf#92546 show results for sub-expressions in formula wizard

Change-Id: I1d5ba707d8dce69abc15ec1de7bec4728bd93adb

diff --git a/formula/source/ui/dlg/formula.cxx 
b/formula/source/ui/dlg/formula.cxx
index 8581e8f..90dfb5b 100644
--- a/formula/source

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

2015-07-06 Thread Benjamin Ni
 sc/inc/simpleformulacalc.hxx  |1 +
 sc/qa/unit/ucalc.cxx  |6 ++
 sc/source/core/data/simpleformulacalc.cxx |5 +
 sc/source/ui/formdlg/formula.cxx  |2 +-
 4 files changed, 13 insertions(+), 1 deletion(-)

New commits:
commit 6a01844a9f504c40758daa570724f1983ab1be79
Author: Benjamin Ni benjaminn...@hotmail.com
Date:   Mon Jul 6 17:35:27 2015 +0200

tdf#92547 - incorrect input values shown in formula wizard

Change-Id: I55dd98b1613376c8e1c83af8ffdc66a58e022cb1

diff --git a/sc/inc/simpleformulacalc.hxx b/sc/inc/simpleformulacalc.hxx
index b701468..340c9d8 100644
--- a/sc/inc/simpleformulacalc.hxx
+++ b/sc/inc/simpleformulacalc.hxx
@@ -41,6 +41,7 @@ public:
 
 void Calculate();
 bool IsValue();
+bool IsMatrix();
 sal_uInt16 GetErrCode();
 double GetValue();
 svl::SharedString GetString();
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 190f522..7c8171c 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -6483,6 +6483,12 @@ void Test::testFormulaWizardSubformula()
 if ( aFCell.GetErrCode() == 0 )
 CPPUNIT_ASSERT_EQUAL( OUString({1, #DIV/0!, #NAME!}), 
aFCell.GetString().getString() );
 
+m_pDoc-SetString(ScAddress(0,1,0), =NA());   // B0
+m_pDoc-SetString(ScAddress(1,1,0), 2);   // B1
+m_pDoc-SetString(ScAddress(2,1,0), =1+2);// B2
+if ( aFCell.GetErrCode() == 0 )
+CPPUNIT_ASSERT_EQUAL(OUString({#N/A, 2, 3}), 
aFCell.GetString().getString());
+
 m_pDoc-DeleteTab(0);
 }
 
diff --git a/sc/source/core/data/simpleformulacalc.cxx 
b/sc/source/core/data/simpleformulacalc.cxx
index 5a08e68..d359667 100644
--- a/sc/source/core/data/simpleformulacalc.cxx
+++ b/sc/source/core/data/simpleformulacalc.cxx
@@ -70,6 +70,11 @@ bool ScSimpleFormulaCalculator::IsValue()
 return maResult.IsValue();
 }
 
+bool ScSimpleFormulaCalculator::IsMatrix()
+{
+return bIsMatrix;
+}
+
 sal_uInt16 ScSimpleFormulaCalculator::GetErrCode()
 {
 Calculate();
diff --git a/sc/source/ui/formdlg/formula.cxx b/sc/source/ui/formdlg/formula.cxx
index 23023b5..4160619 100644
--- a/sc/source/ui/formdlg/formula.cxx
+++ b/sc/source/ui/formdlg/formula.cxx
@@ -330,7 +330,7 @@ bool ScFormulaDlg::calculateValue( const OUString rStrExp, 
OUString rStrResult
 }
 
 sal_uInt16 nErrCode = pFCell-GetErrCode();
-if ( nErrCode == 0 )
+if ( nErrCode == 0 || pFCell-IsMatrix() )
 {
 SvNumberFormatter aFormatter = *(pDoc-GetFormatTable());
 Color* pColor;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/unitver' - sc/source

2015-07-05 Thread Benjamin Ni
 sc/source/core/units/unitsimpl.cxx |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

New commits:
commit c565edd82b3bf77a9e2333610b495a2916e4ab16
Author: Benjamin Ni benjaminn...@hotmail.com
Date:   Fri Jul 3 16:45:52 2015 +0100

tdf#92455 - inconsistent unit handling

Change-Id: Ifbb85a32ef9d84199d17cedd28fa0f9e66eabf66

diff --git a/sc/source/core/units/unitsimpl.cxx 
b/sc/source/core/units/unitsimpl.cxx
index c2e39f9..0c89201 100644
--- a/sc/source/core/units/unitsimpl.cxx
+++ b/sc/source/core/units/unitsimpl.cxx
@@ -789,8 +789,9 @@ bool UnitsImpl::convertCellUnitsForColumnRange(const 
ScRange rRange,
 }
 }
 
-bool bLocalAnnotationRequired = (aHeader.address  
!rRange.In(*aHeader.address)) 
-(rOutputUnit != aHeader.unit);
+bool bLocalAnnotationRequired = !aHeader.address || (
+!rRange.In(*aHeader.address) 
+(rOutputUnit != aHeader.unit) );
 double nValue = pDoc-GetValue(aCurrent);
 
 if (!aLocalUnit.areConvertibleTo(rOutputUnit))
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/unitver' - officecfg/registry sc/inc sc/source sc/uiconfig

2015-07-05 Thread Benjamin Ni
 officecfg/registry/schema/org/openoffice/Office/Calc.xcs |7 +
 sc/inc/formulaopt.hxx|4 
 sc/source/core/tool/formulaopt.cxx   |   58 +-
 sc/source/ui/inc/tpformula.hxx   |1 
 sc/source/ui/optdlg/tpformula.cxx|9 ++
 sc/source/ui/view/viewfunc.cxx   |   61 ---
 sc/uiconfig/scalc/ui/optformula.ui   |   17 
 7 files changed, 111 insertions(+), 46 deletions(-)

New commits:
commit fc2a471d90521e1a9500b27088bbd122002049b0
Author: Benjamin Ni benjaminn...@hotmail.com
Date:   Fri Jul 3 04:40:29 2015 +0100

Added checkbox and config option to toggle unit verification

Change-Id: Ie218821d05466b77ed42a26365b04a6798dec067

diff --git a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs 
b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
index bb74d74..d25ef1c 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
@@ -1424,6 +1424,13 @@
   /info
   valuefalse/value
 /prop
+prop oor:name=UnitValidat oor:type=xs:boolean 
oor:nillable=false
+  !-- UIHints: Tools - Options  Spreadsheet  Formula --
+  info
+descWhether to check for unit consistency upon entering 
formulae./desc
+  /info
+  valuefalse/value
+/prop
 prop oor:name=SeparatorArg oor:type=xs:string 
oor:nillable=false
   !-- UIHints: Tools - Options  Spreadsheet  Formula --
   info
diff --git a/sc/inc/formulaopt.hxx b/sc/inc/formulaopt.hxx
index 5b71b2a..b3ad9f6 100644
--- a/sc/inc/formulaopt.hxx
+++ b/sc/inc/formulaopt.hxx
@@ -23,6 +23,7 @@ class SC_DLLPUBLIC ScFormulaOptions
 {
 private:
 bool bUseEnglishFuncName; // use English function name even if the 
locale is not English.
+bool bUnitValidat;
 formula::FormulaGrammar::Grammar eFormulaGrammar;  // formula grammar used 
to switch different formula syntax
 ScCalcConfig aCalcConfig;
 
@@ -50,6 +51,9 @@ public:
 void SetUseEnglishFuncName( bool bVal ) { bUseEnglishFuncName = bVal; }
 bool GetUseEnglishFuncName() const { return bUseEnglishFuncName; }
 
+void SetUnitValidat( bool bVal ) { bUnitValidat = bVal; }
+bool GetUnitValidat() const { return bUnitValidat; }
+
 void SetFormulaSepArg(const OUString rSep) { aFormulaSepArg = rSep; }
 OUString GetFormulaSepArg() const { return aFormulaSepArg; }
 
diff --git a/sc/source/core/tool/formulaopt.cxx 
b/sc/source/core/tool/formulaopt.cxx
index 1e0a5f5..8e7e54f 100644
--- a/sc/source/core/tool/formulaopt.cxx
+++ b/sc/source/core/tool/formulaopt.cxx
@@ -34,8 +34,9 @@ ScFormulaOptions::ScFormulaOptions()
 
 ScFormulaOptions::ScFormulaOptions( const ScFormulaOptions rCpy ) :
 bUseEnglishFuncName ( rCpy.bUseEnglishFuncName ),
+bUnitValidat( rCpy.bUnitValidat ),
 eFormulaGrammar ( rCpy.eFormulaGrammar ),
-aCalcConfig(rCpy.aCalcConfig),
+aCalcConfig ( rCpy.aCalcConfig ),
 aFormulaSepArg  ( rCpy.aFormulaSepArg ),
 aFormulaSepArrayRow ( rCpy.aFormulaSepArrayRow ),
 aFormulaSepArrayCol ( rCpy.aFormulaSepArrayCol ),
@@ -51,6 +52,7 @@ ScFormulaOptions::~ScFormulaOptions()
 void ScFormulaOptions::SetDefaults()
 {
 bUseEnglishFuncName = false;
+bUnitValidat = false;
 eFormulaGrammar = ::formula::FormulaGrammar::GRAM_NATIVE;
 meOOXMLRecalc = RECALC_ASK;
 meODFRecalc = RECALC_ASK;
@@ -127,8 +129,9 @@ const LocaleDataWrapper 
ScFormulaOptions::GetLocaleDataWrapper()
 ScFormulaOptions ScFormulaOptions::operator=( const ScFormulaOptions rCpy )
 {
 bUseEnglishFuncName = rCpy.bUseEnglishFuncName;
+bUnitValidat= rCpy.bUnitValidat;
 eFormulaGrammar = rCpy.eFormulaGrammar;
-aCalcConfig = rCpy.aCalcConfig;
+aCalcConfig = rCpy.aCalcConfig;
 aFormulaSepArg  = rCpy.aFormulaSepArg;
 aFormulaSepArrayRow = rCpy.aFormulaSepArrayRow;
 aFormulaSepArrayCol = rCpy.aFormulaSepArrayCol;
@@ -140,8 +143,9 @@ ScFormulaOptions ScFormulaOptions::operator=( const 
ScFormulaOptions rCpy )
 bool ScFormulaOptions::operator==( const ScFormulaOptions rOpt ) const
 {
 return bUseEnglishFuncName == rOpt.bUseEnglishFuncName
+ bUnitValidat== rOpt.bUnitValidat
  eFormulaGrammar == rOpt.eFormulaGrammar
- aCalcConfig == rOpt.aCalcConfig
+ aCalcConfig == rOpt.aCalcConfig
  aFormulaSepArg  == rOpt.aFormulaSepArg
  aFormulaSepArrayRow == rOpt.aFormulaSepArrayRow
  aFormulaSepArrayCol == rOpt.aFormulaSepArrayCol
@@ -185,22 +189,23 @@ SfxPoolItem* ScTpFormulaItem::Clone( SfxItemPool * ) const
 
 #define CFGPATH_FORMULA   Office.Calc/Formula
 
-#define SCFORMULAOPT_GRAMMAR  0
-#define SCFORMULAOPT_ENGLISH_FUNCNAME 1
-#define SCFORMULAOPT_SEP_ARG

[Libreoffice-commits] core.git: Branch 'feature/unitver' - sc/source

2015-07-05 Thread Benjamin Ni
 sc/source/core/units/unitsimpl.cxx |   37 ++---
 1 file changed, 26 insertions(+), 11 deletions(-)

New commits:
commit aa81c5e795bac029964cab7708f3dab278ce236f
Author: Benjamin Ni benjaminn...@hotmail.com
Date:   Fri Jul 3 15:20:19 2015 +0100

Coding style cleanup

Change-Id: I6171ba59e4df40dfc4734204832857f0fe7637e9
Reviewed-on: https://gerrit.libreoffice.org/16738
Reviewed-by: Markus Mohrhard markus.mohrh...@googlemail.com
Tested-by: Markus Mohrhard markus.mohrh...@googlemail.com

diff --git a/sc/source/core/units/unitsimpl.cxx 
b/sc/source/core/units/unitsimpl.cxx
index 4f0057c..c2e39f9 100644
--- a/sc/source/core/units/unitsimpl.cxx
+++ b/sc/source/core/units/unitsimpl.cxx
@@ -751,19 +751,24 @@ bool UnitsImpl::convertCellUnitsForColumnRange(const 
ScRange rRange,
 // It's possible that the header refers to an incompatible unit, hence
 // shouldn't be modified when we're converting.
 if (aCurrent == aHeader.address 
-aHeader.unit.areConvertibleTo(rOutputUnit)) {
+aHeader.unit.areConvertibleTo(rOutputUnit) )
+{
 OUString sHeader = pDoc-GetString(aCurrent);
 sHeader = sHeader.replaceAt(aHeader.unitStringPosition, 
aHeader.unitString.getLength(), *rOutputUnit.getInputString());
 pDoc-SetString(aCurrent, sHeader);
 
 aHeader.valid = false;
-} else if (pDoc-GetCellType(aCurrent) != CELLTYPE_STRING) {
-if (!aHeader.valid) {
+}
+else if (pDoc-GetCellType(aCurrent) != CELLTYPE_STRING)
+{
+if (!aHeader.valid)
+{
 aHeader = findHeaderUnitForCell(aCurrent, pDoc);
 
 // If there is no header we get an invalid unit returned from 
findHeaderUnitForCell,
 // and therfore assume the dimensionless unit 1.
-if (!aHeader.valid) {
+if (!aHeader.valid)
+{
 UtUnit::createUnit(, aHeader.unit, mpUnitSystem);
 aHeader.valid = true;
 }
@@ -771,10 +776,14 @@ bool UnitsImpl::convertCellUnitsForColumnRange(const 
ScRange rRange,
 
 OUString sLocalUnit(extractUnitStringForCell(aCurrent, pDoc));
 UtUnit aLocalUnit;
-if (sLocalUnit.isEmpty()) {
+if (sLocalUnit.isEmpty())
+{
 aLocalUnit = aHeader.unit;
-} else { // override header unit with annotation unit
-if (!UtUnit::createUnit(sLocalUnit, aLocalUnit, mpUnitSystem)) 
{
+}
+else
+{ // override header unit with annotation unit
+if (!UtUnit::createUnit(sLocalUnit, aLocalUnit, mpUnitSystem))
+{
 // but assume dimensionless if invalid
 UtUnit::createUnit(, aLocalUnit, mpUnitSystem);
 }
@@ -784,13 +793,17 @@ bool UnitsImpl::convertCellUnitsForColumnRange(const 
ScRange rRange,
 (rOutputUnit != aHeader.unit);
 double nValue = pDoc-GetValue(aCurrent);
 
-if (!aLocalUnit.areConvertibleTo(rOutputUnit)) {
+if (!aLocalUnit.areConvertibleTo(rOutputUnit))
+{
 bAllConverted = false;
-} else {
+}
+else
+{
 double nNewValue = aLocalUnit.convertValueTo(nValue, 
rOutputUnit);
 pDoc-SetValue(aCurrent, nNewValue);
 
-if (bLocalAnnotationRequired) {
+if (bLocalAnnotationRequired)
+{
 // All a local dirty hack too - needs to be refactored and 
improved.
 // And ideally we should reuse the existing format.
 OUString sNewFormat = General\ + 
*rOutputUnit.getInputString() + \;
@@ -801,7 +814,9 @@ bool UnitsImpl::convertCellUnitsForColumnRange(const 
ScRange rRange,
 SvNumberFormatter* pFormatter = pDoc-GetFormatTable();
 pFormatter-PutEntry(sNewFormat, nErrorPosition, nType, 
nFormatKey);
 pDoc-SetNumberFormat(aCurrent, nFormatKey);
-} else {
+}
+else
+{
 // The number formats will by definition be wrong once 
we've converted, so just reset completely.
 pDoc-SetNumberFormat(aCurrent, 0);
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/unitver' - 2 commits - sc/qa sc/source

2015-06-30 Thread Benjamin Ni
 sc/qa/unit/units.cxx |  149 +++
 sc/source/ui/miscdlgs/unitsconversiondlg.cxx |7 +
 2 files changed, 116 insertions(+), 40 deletions(-)

New commits:
commit b290ccb0b3979e7ad344709b4d1018fee071f52a
Author: Benjamin Ni benjaminn...@hotmail.com
Date:   Tue Jun 30 06:40:38 2015 +0100

Added more range conversion tests

Change-Id: If4898e6c70cb9731af35d51457de28410f808b96

diff --git a/sc/qa/unit/units.cxx b/sc/qa/unit/units.cxx
index ee6af8a..28cffa2 100644
--- a/sc/qa/unit/units.cxx
+++ b/sc/qa/unit/units.cxx
@@ -321,6 +321,13 @@ void UnitsTest::testUnitVerification() {
 pTokens = pCell-GetCode();
 CPPUNIT_ASSERT(mpUnitsImpl-verifyFormula(pTokens, address, mpDoc) == 
FormulaStatus::VALID);
 
+// SUM(cm,m)
+address.IncRow();
+mpDoc-SetFormula(address, =SUM(A1,E1));
+pCell = mpDoc-GetFormulaCell(address);
+pTokens = pCell-GetCode();
+CPPUNIT_ASSERT(mpUnitsImpl-verifyFormula(pTokens, address, mpDoc) == 
FormulaStatus::ERROR_INPUT_SCALING);
+
 // PRODUCT(cm/,s)+cm
 address.IncRow();
 mpDoc-SetFormula(address, =PRODUCT(C1:D1)+A1);
@@ -803,82 +810,144 @@ void UnitsTest::testRangeConversion() {
 mpDoc-EnsureTable(nTab);
 
 // Column 1: convert [cm] to [cm].
-ScAddress headerAddress(0, 0, nTab);
-mpDoc-SetString(headerAddress, length [cm]);
+ScAddress headerAddressCol1(0, 0, nTab);
+mpDoc-SetString(headerAddressCol1, length [cm]);
 
-ScAddress address(headerAddress);
+ScAddress addressCol1(headerAddressCol1);
 
 vectordouble values({10, 20, 30, 40, 1, 0.5, 0.25});
-address.IncRow();
-mpDoc-SetValues(address, values);
+addressCol1.IncRow();
+mpDoc-SetValues(addressCol1, values);
 
 // Test conversion of range _not_ including header
-ScAddress endAddress( address.Col(), address.Row() + values.size() - 1, 
nTab);
+ScAddress endAddressCol1( addressCol1.Col(), addressCol1.Row() + 
values.size() - 1, nTab);
 
-ScRange aRange(address, endAddress);
+ScRange aRange(addressCol1, endAddressCol1);
 CPPUNIT_ASSERT(mpUnitsImpl-convertCellUnits(aRange, mpDoc, cm));
 CPPUNIT_ASSERT(!mpUnitsImpl-convertCellUnits(aRange, mpDoc, kg));
 
-CPPUNIT_ASSERT(mpDoc-GetString(headerAddress) == length [cm]);
+CPPUNIT_ASSERT(mpDoc-GetString(headerAddressCol1) == length [cm]);
 
-for (double d: values) {
+for (double d: values)
+{
 // Test that the value is unchanged
-CPPUNIT_ASSERT(mpDoc-GetValue(address) == d);
+CPPUNIT_ASSERT(mpDoc-GetValue(addressCol1) == d);
 // And NO annotation has been added
-CPPUNIT_ASSERT(mpDoc-GetString(address) == OUString::number(d));
-address.IncRow();
+CPPUNIT_ASSERT(mpDoc-GetString(addressCol1) == OUString::number(d));
+addressCol1.IncRow();
 }
 
 // Test conversion of range including header (from cm to cm)
-aRange = ScRange(headerAddress, endAddress);
+aRange = ScRange(headerAddressCol1, endAddressCol1);
 CPPUNIT_ASSERT(mpUnitsImpl-convertCellUnits(aRange, mpDoc, cm));
 CPPUNIT_ASSERT(!mpUnitsImpl-convertCellUnits(aRange, mpDoc, kg));
 
-CPPUNIT_ASSERT(mpDoc-GetString(headerAddress) == length [cm]);
+CPPUNIT_ASSERT(mpDoc-GetString(headerAddressCol1) == length [cm]);
 
-address = headerAddress;
-address.IncRow();
-for (double d: values) {
-CPPUNIT_ASSERT_DOUBLES_EQUAL(mpDoc-GetValue(address), d, 1e-7);
+addressCol1 = headerAddressCol1;
+addressCol1.IncRow();
+for (double d: values)
+{
+CPPUNIT_ASSERT_DOUBLES_EQUAL(mpDoc-GetValue(addressCol1), d, 1e-7);
 // And NO annotation has been added
-CPPUNIT_ASSERT(mpDoc-GetString(address) == OUString::number(d));
-address.IncRow();
+CPPUNIT_ASSERT(mpDoc-GetString(addressCol1) == OUString::number(d));
+addressCol1.IncRow();
 }
 
 // Convert just the values (but not header): [cm] to [m]
-address.SetRow(1);
-aRange = ScRange(address, endAddress);
+addressCol1.SetRow(1);
+aRange = ScRange(addressCol1, endAddressCol1);
 CPPUNIT_ASSERT(mpUnitsImpl-convertCellUnits(aRange, mpDoc, m));
 
-CPPUNIT_ASSERT(mpDoc-GetString(headerAddress) == length [cm]);
+CPPUNIT_ASSERT(mpDoc-GetString(headerAddressCol1) == length [cm]);
 
-for (double d: values) {
-CPPUNIT_ASSERT_DOUBLES_EQUAL(mpDoc-GetValue(address), d/100, 1e-7);
-// AND test annotation
-// Disabled for now until the precision problems are figured out
-// CPPUNIT_ASSERT(mpDoc-GetString(address) == OUString::number(d/100) 
+ m);
-address.IncRow();
+for (double d: values)
+{
+OUString aResultStr = mpDoc-GetString(addressCol1);
+OUString aValStr  = aResultStr.copy( 0, aResultStr.getLength() - 1 ); 
// value portion of result
+OUString aUnitStr = aResultStr.copy( aResultStr.getLength() - 1, 1 ); 
// annotation portion of result

[Libreoffice-commits] core.git: sc/inc sc/qa sc/source sc/uiconfig

2015-05-30 Thread Benjamin Ni
 sc/inc/column.hxx  |1 
 sc/inc/dociter.hxx |   18 ++
 sc/inc/document.hxx|4 ++
 sc/inc/table.hxx   |1 
 sc/qa/unit/ucalc.cxx   |   12 ++
 sc/source/core/data/dociter.cxx|   52 +
 sc/source/core/data/document.cxx   |   15 
 sc/source/ui/docshell/tpstat.cxx   |2 +
 sc/source/ui/inc/tpstat.hxx|1 
 sc/source/ui/view/cellsh2.cxx  |   18 +-
 sc/uiconfig/scalc/ui/statisticsinfopage.ui |   32 +
 11 files changed, 155 insertions(+), 1 deletion(-)

New commits:
commit 51262ef0d11d9aef246001d8a9b1c1d8753023bd
Author: Benjamin Ni benjaminn...@hotmail.com
Date:   Wed May 27 09:00:45 2015 +0100

Implemented formula group count statistic

Change-Id: I8b9c11fdd4b6e4343b467f1e5b1d1e96f1dd3140
Reviewed-on: https://gerrit.libreoffice.org/15927
Tested-by: Jenkins c...@libreoffice.org
Reviewed-by: Markus Mohrhard markus.mohrh...@googlemail.com

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 9d96793..d5e6625 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -145,6 +145,7 @@ friend class ScValueIterator;
 friend class ScHorizontalValueIterator;
 friend class ScDBQueryDataIterator;
 friend class ScQueryCellIterator;
+friend class ScFormulaGroupIterator;
 friend class ScCellIterator;
 friend class ScHorizontalCellIterator;
 friend class ScHorizontalAttrIterator;
diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx
index 5b32930..49a782e 100644
--- a/sc/inc/dociter.hxx
+++ b/sc/inc/dociter.hxx
@@ -21,6 +21,7 @@
 #define INCLUDED_SC_INC_DOCITER_HXX
 
 #include address.hxx
+#include formulagroup.hxx
 #include tools/solar.h
 #include global.hxx
 #include scdllapi.h
@@ -184,6 +185,23 @@ public:
 boolGetNext(Value rValue);
 };
 
+class ScFormulaGroupIterator
+{
+private:
+ScDocument* mpDoc;
+SCTAB mnTab;
+SCCOL mnCol;
+bool mbNullCol;
+size_t mnIndex;
+std::vectorsc::FormulaGroupEntry maEntries;
+
+public:
+ScFormulaGroupIterator( ScDocument* pDoc );
+
+sc::FormulaGroupEntry* first();
+sc::FormulaGroupEntry* next();
+};
+
 /**
  * Walk through all cells in an area. For SubTotal and Aggregate depending on 
mnSubTotalFlags.
  **/
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 7ea90f1..79ea555 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -231,10 +231,12 @@ struct ScDocStat
 OUString  aDocName;
 SCTAB   nTableCount;
 sal_uLong   nCellCount;
+sal_uLong   nFormulaCount;
 sal_uInt16  nPageCount;
 ScDocStat()
 : nTableCount(0)
 , nCellCount(0)
+, nFormulaCount(0)
 , nPageCount(0)
 {
 }
@@ -251,6 +253,7 @@ class ScDocument
 friend class ScValueIterator;
 friend class ScHorizontalValueIterator;
 friend class ScDBQueryDataIterator;
+friend class ScFormulaGroupIterator;
 friend class ScCellIterator;
 friend class ScQueryCellIterator;
 friend class ScHorizontalCellIterator;
@@ -465,6 +468,7 @@ public:
 bool  IsUsingEmbededFonts() { return mbUseEmbedFonts; }
 void  SetIsUsingEmbededFonts( bool bUse ) { mbUseEmbedFonts = 
bUse; }
 SC_DLLPUBLIC sal_uLong  GetCellCount() const;   // all cells
+SC_DLLPUBLIC sal_uLong  GetFormulaGroupCount() const;   // all 
cells
 sal_uLong   GetCodeCount() const;   // RPN-Code in formulas
 DECL_LINK( GetUserDefinedColor, sal_uInt16 * );
 // number 
formatter
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 7454188..8bbf7df 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -209,6 +209,7 @@ friend class ScDocument;// for FillInfo
 friend class ScValueIterator;
 friend class ScHorizontalValueIterator;
 friend class ScDBQueryDataIterator;
+friend class ScFormulaGroupIterator;
 friend class ScCellIterator;
 friend class ScQueryCellIterator;
 friend class ScHorizontalCellIterator;
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 494b535..dcc8cc1 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -767,6 +767,18 @@ void Test::testDocStatistics()
 m_pDoc-SetString(ScAddress(1,1,1), Test);
 CPPUNIT_ASSERT_EQUAL(static_castsal_uLong(3), m_pDoc-GetCellCount());
 
+CPPUNIT_ASSERT_EQUAL(static_castsal_uLong(0), 
m_pDoc-GetFormulaGroupCount());
+m_pDoc-SetString(ScAddress(3,0,1), =A1);
+CPPUNIT_ASSERT_EQUAL(static_castsal_uLong(1), 
m_pDoc-GetFormulaGroupCount());
+m_pDoc-SetString(ScAddress(3,1,1), =A2);
+m_pDoc-SetString(ScAddress(3,2,1), =A3);
+CPPUNIT_ASSERT_EQUAL(static_castsal_uLong(1), 
m_pDoc-GetFormulaGroupCount());
+m_pDoc-SetString(ScAddress(3,3,1), =A5);
+m_pDoc-SetString(ScAddress(3,4,1), =A6);
+CPPUNIT_ASSERT_EQUAL