summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Ni <benjaminniri@hotmail.com>2015-05-27 09:00:45 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2015-05-30 09:06:58 +0000
commit51262ef0d11d9aef246001d8a9b1c1d8753023bd (patch)
tree182de28064a0d9e58a3e0f3c0a2dd0aa735293b8
parentScrollFlags conversion "typo" - fixes scrolling repaint problems (diff)
downloadcore-51262ef0d11d9aef246001d8a9b1c1d8753023bd.tar.gz
core-51262ef0d11d9aef246001d8a9b1c1d8753023bd.zip
Implemented formula group count statistic
Change-Id: I8b9c11fdd4b6e4343b467f1e5b1d1e96f1dd3140 Reviewed-on: https://gerrit.libreoffice.org/15927 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
-rw-r--r--sc/inc/column.hxx1
-rw-r--r--sc/inc/dociter.hxx18
-rw-r--r--sc/inc/document.hxx4
-rw-r--r--sc/inc/table.hxx1
-rw-r--r--sc/qa/unit/ucalc.cxx12
-rw-r--r--sc/source/core/data/dociter.cxx52
-rw-r--r--sc/source/core/data/document.cxx15
-rw-r--r--sc/source/ui/docshell/tpstat.cxx2
-rw-r--r--sc/source/ui/inc/tpstat.hxx1
-rw-r--r--sc/source/ui/view/cellsh2.cxx18
-rw-r--r--sc/uiconfig/scalc/ui/statisticsinfopage.ui32
11 files changed, 155 insertions, 1 deletions
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 9d9679308d49..d5e66254d243 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 5b32930858b7..49a782e3fe3c 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:
bool GetNext(Value& rValue);
};
+class ScFormulaGroupIterator
+{
+private:
+ ScDocument* mpDoc;
+ SCTAB mnTab;
+ SCCOL mnCol;
+ bool mbNullCol;
+ size_t mnIndex;
+ std::vector<sc::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 7ea90f19015f..79ea55532137 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 7454188f04a7..8bbf7df98f13 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 494b5356b8da..dcc8cc17c493 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_cast<sal_uLong>(3), m_pDoc->GetCellCount());
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uLong>(0), m_pDoc->GetFormulaGroupCount());
+ m_pDoc->SetString(ScAddress(3,0,1), "=A1");
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_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_cast<sal_uLong>(1), m_pDoc->GetFormulaGroupCount());
+ m_pDoc->SetString(ScAddress(3,3,1), "=A5");
+ m_pDoc->SetString(ScAddress(3,4,1), "=A6");
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uLong>(2), m_pDoc->GetFormulaGroupCount());
+ m_pDoc->SetString(ScAddress(3,1,1), "=A3");
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uLong>(4), m_pDoc->GetFormulaGroupCount());
+
m_pDoc->DeleteTab(1);
CPPUNIT_ASSERT_MESSAGE("Failed to decrement sheet count.", m_pDoc->GetTableCount() == nStartTabs+1);
m_pDoc->DeleteTab(0); // This may fail in case there is only one sheet in the document.
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 8cf40b61a421..575f13f465d6 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -785,6 +785,58 @@ bool ScDBQueryDataIterator::GetNext(Value& rValue)
return mpData->getNext(rValue);
}
+ScFormulaGroupIterator::ScFormulaGroupIterator( ScDocument* pDoc ) :
+ mpDoc(pDoc),
+ mnTab(0),
+ mnCol(0),
+ mnIndex(0)
+{
+ ScTable *pTab = mpDoc->FetchTable(mnTab);
+ ScColumn *pCol = pTab->FetchColumn(mnCol);
+ if (pCol)
+ {
+ mbNullCol = false;
+ maEntries = pCol->GetFormulaGroupEntries();
+ }
+ else
+ mbNullCol = true;
+}
+
+sc::FormulaGroupEntry* ScFormulaGroupIterator::first()
+{
+ return this->next();
+}
+
+sc::FormulaGroupEntry* ScFormulaGroupIterator::next()
+{
+ if (mnIndex >= maEntries.size() || mbNullCol)
+ {
+ while (mnIndex >= maEntries.size() || mbNullCol)
+ {
+ mnIndex = 0;
+ mnCol++;
+ if (mnCol > MAXCOL)
+ {
+ mnCol = 0;
+ mnTab++;
+ if (mnTab >= mpDoc->GetTableCount())
+ return NULL;
+ }
+ ScTable *pTab = mpDoc->FetchTable(mnTab);
+ ScColumn *pCol = pTab->FetchColumn(mnCol);
+ if (pCol)
+ {
+ mbNullCol = false;
+ maEntries = pCol->GetFormulaGroupEntries();
+ }
+ else
+ mbNullCol = true;
+ }
+ }
+
+ return &maEntries[mnIndex++];
+}
+
ScCellIterator::ScCellIterator( ScDocument* pDoc, const ScRange& rRange, sal_uInt16 nSubTotalFlags ) :
mpDoc(pDoc),
maStartPos(rRange.aStart),
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index c445d63fcd62..b45bc8e8f869 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -47,6 +47,7 @@
#include "document.hxx"
#include "table.hxx"
+#include "column.hxx"
#include "attrib.hxx"
#include "attarray.hxx"
#include "markarr.hxx"
@@ -5748,6 +5749,19 @@ sal_uLong ScDocument::GetCellCount() const
return nCellCount;
}
+sal_uLong ScDocument::GetFormulaGroupCount() const
+{
+ sal_uLong nFormulaGroupCount = 0L;
+
+ ScFormulaGroupIterator aIter( const_cast<ScDocument*>(this) );
+ for ( sc::FormulaGroupEntry* ptr = aIter.first(); ptr; ptr = aIter.next())
+ {
+ nFormulaGroupCount++;
+ }
+
+ return nFormulaGroupCount;
+}
+
sal_uLong ScDocument::GetCodeCount() const
{
sal_uLong nCodeCount = 0;
@@ -5832,6 +5846,7 @@ void ScDocument::GetDocStat( ScDocStat& rDocStat )
{
rDocStat.nTableCount = GetTableCount();
rDocStat.aDocName = aDocName;
+ rDocStat.nFormulaCount = GetFormulaGroupCount();
rDocStat.nCellCount = GetCellCount();
}
diff --git a/sc/source/ui/docshell/tpstat.cxx b/sc/source/ui/docshell/tpstat.cxx
index 7aca08e43042..c18f331790e1 100644
--- a/sc/source/ui/docshell/tpstat.cxx
+++ b/sc/source/ui/docshell/tpstat.cxx
@@ -38,6 +38,7 @@ ScDocStatPage::ScDocStatPage( vcl::Window *pParent, const SfxItemSet& rSet )
get(m_pFtTables,"nosheets");
get(m_pFtCells,"nocells");
get(m_pFtPages,"nopages");
+ get(m_pFtFormula,"noformula");
ScDocShell* pDocSh = PTR_CAST( ScDocShell, SfxObjectShell::Current() );
ScDocStat aDocStat;
@@ -51,6 +52,7 @@ ScDocStatPage::ScDocStatPage( vcl::Window *pParent, const SfxItemSet& rSet )
m_pFtTables ->SetText( OUString::number( aDocStat.nTableCount ) );
m_pFtCells ->SetText( OUString::number( aDocStat.nCellCount ) );
m_pFtPages ->SetText( OUString::number( aDocStat.nPageCount ) );
+ m_pFtFormula ->SetText( OUString::number( aDocStat.nFormulaCount ) );
}
diff --git a/sc/source/ui/inc/tpstat.hxx b/sc/source/ui/inc/tpstat.hxx
index a5cbdf7a925e..d143610c37b9 100644
--- a/sc/source/ui/inc/tpstat.hxx
+++ b/sc/source/ui/inc/tpstat.hxx
@@ -41,6 +41,7 @@ private:
VclPtr<FixedText> m_pFtTables;
VclPtr<FixedText> m_pFtCells;
VclPtr<FixedText> m_pFtPages;
+ VclPtr<FixedText> m_pFtFormula;
};
#endif
diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx
index 0ba222434e9d..4eb52acc07a7 100644
--- a/sc/source/ui/view/cellsh2.cxx
+++ b/sc/source/ui/view/cellsh2.cxx
@@ -887,11 +887,27 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
ScGlobal::pLocaleData->getNumDecimalSep()[0], true));
else
aExpr2 = aTemp2;
+ if ( eMode == SC_VALID_TIME ) {
+ sal_Int32 wraparound = aExpr1.compareTo(aExpr2);
+ if (wraparound > 0) {
+ if (eOper == SC_COND_BETWEEN) {
+ eOper = SC_COND_NOTBETWEEN;
+ OUString tmp = aExpr1;
+ aExpr1 = aExpr2;
+ aExpr2 = tmp;
+ }
+ else if (eOper == SC_COND_NOTBETWEEN) {
+ eOper = SC_COND_BETWEEN;
+ OUString tmp = aExpr1;
+ aExpr1 = aExpr2;
+ aExpr2 = tmp;
+ }
+ }
+ }
}
else
aExpr2 = aTemp2;
}
-
if ( pOutSet->GetItemState( FID_VALID_BLANK, true, &pItem ) == SfxItemState::SET )
bBlank = static_cast<const SfxBoolItem*>(pItem)->GetValue();
if ( pOutSet->GetItemState( FID_VALID_LISTTYPE, true, &pItem ) == SfxItemState::SET )
diff --git a/sc/uiconfig/scalc/ui/statisticsinfopage.ui b/sc/uiconfig/scalc/ui/statisticsinfopage.ui
index 14955b497290..f3f648db7158 100644
--- a/sc/uiconfig/scalc/ui/statisticsinfopage.ui
+++ b/sc/uiconfig/scalc/ui/statisticsinfopage.ui
@@ -113,6 +113,38 @@
<property name="height">1</property>
</packing>
</child>
+ <child>
+ <object class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Number of Formula Groups:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">noformula</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">3</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="noformula">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="xalign">0</property>
+ <property name="use_underline">True</property>
+ <property name="width_chars">10</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">3</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
</object>
</child>
</object>