summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-03-14 11:56:53 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-03-15 10:29:31 +0000
commitc9da7f6bfe25d217fe3fdd09b82b95e9491cd8e3 (patch)
treec7150e564d45a9e1eab10d19904610e807a867eb
parent6c3968e234e8ee49103921930de87801bcc048bc (diff)
introduce ScGeneralFunction scoped enum
to abstract over css::sheet::GeneralFunction and css::sheet::GeneralFunction2 Change-Id: I4d4df35a249bf66e12240a3b94948918f1f3ef8a Reviewed-on: https://gerrit.libreoffice.org/35168 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sc/inc/dapiuno.hxx7
-rw-r--r--sc/inc/dpsave.hxx13
-rw-r--r--sc/inc/dptabsrc.hxx12
-rw-r--r--sc/inc/dputil.hxx4
-rw-r--r--sc/inc/generalfunction.hxx104
-rw-r--r--sc/qa/unit/subsequent_export-test.cxx9
-rw-r--r--sc/qa/unit/subsequent_filters-test.cxx3
-rw-r--r--sc/qa/unit/ucalc_pivottable.cxx123
-rw-r--r--sc/source/core/data/dpobject.cxx10
-rw-r--r--sc/source/core/data/dpsave.cxx11
-rw-r--r--sc/source/core/data/dptabres.cxx5
-rw-r--r--sc/source/core/data/dptabsrc.cxx38
-rw-r--r--sc/source/core/data/dputil.cxx55
-rw-r--r--sc/source/filter/excel/xepivot.cxx28
-rw-r--r--sc/source/filter/excel/xipivot.cxx2
-rw-r--r--sc/source/filter/excel/xlpivot.cxx108
-rw-r--r--sc/source/filter/inc/xlpivot.hxx7
-rw-r--r--sc/source/filter/xml/XMLConverter.cxx31
-rw-r--r--sc/source/filter/xml/XMLConverter.hxx4
-rw-r--r--sc/source/filter/xml/xmldpimp.cxx5
-rw-r--r--sc/source/filter/xml/xmldpimp.hxx12
-rw-r--r--sc/source/filter/xml/xmldrani.cxx2
-rw-r--r--sc/source/ui/unoobj/cellsuno.cxx2
-rw-r--r--sc/source/ui/unoobj/dapiuno.cxx86
-rw-r--r--sc/source/ui/unoobj/datauno.cxx6
-rw-r--r--sc/source/ui/view/dbfunc3.cxx3
26 files changed, 392 insertions, 298 deletions
diff --git a/sc/inc/dapiuno.hxx b/sc/inc/dapiuno.hxx
index 894755d74421..db0449decf9b 100644
--- a/sc/inc/dapiuno.hxx
+++ b/sc/inc/dapiuno.hxx
@@ -65,11 +65,12 @@ struct ScDPNumGroupInfo;
class ScDataPilotTableObj;
class ScDataPilotFieldObj;
class ScDataPilotItemObj;
+enum class ScGeneralFunction;
class ScDataPilotConversion
{
public:
- static sal_Int16 FirstFunc( PivotFunc nBits );
+ static ScGeneralFunction FirstFunc( PivotFunc nBits );
static PivotFunc FunctionBit( sal_Int16 eFunc );
static void FillGroupInfo(
@@ -445,9 +446,9 @@ public:
css::sheet::DataPilotFieldOrientation getOrientation() const;
void setOrientation(css::sheet::DataPilotFieldOrientation Orientation);
sal_Int16 getFunction() const;
- void setFunction(sal_Int16 Function);
+ void setFunction(ScGeneralFunction Function);
css::uno::Sequence< sal_Int16 > getSubtotals() const;
- void setSubtotals(const css::uno::Sequence< sal_Int16 >& rFunctions);
+ void setSubtotals(const std::vector< ScGeneralFunction >& rFunctions);
void setCurrentPage(const OUString& sPage);
void setUseCurrentPage(bool bUse);
const css::sheet::DataPilotFieldAutoShowInfo* getAutoShowInfo();
diff --git a/sc/inc/dpsave.hxx b/sc/inc/dpsave.hxx
index db5b8ace0ae0..624ed3f7e080 100644
--- a/sc/inc/dpsave.hxx
+++ b/sc/inc/dpsave.hxx
@@ -44,6 +44,7 @@ namespace com { namespace sun { namespace star { namespace sheet {
class ScDPDimensionSaveData;
class ScDPTableData;
+enum class ScGeneralFunction;
// classes to save Data Pilot settings
@@ -98,12 +99,12 @@ private:
bool bIsDataLayout;
bool bDupFlag;
sal_uInt16 nOrientation;
- sal_uInt16 nFunction; // GeneralFunction2, for data dimensions
+ ScGeneralFunction nFunction; // for data dimensions
long nUsedHierarchy;
sal_uInt16 nShowEmptyMode; //! at level
bool bRepeatItemLabels; //! at level
bool bSubTotalDefault; //! at level
- std::vector<sal_uInt16> maSubTotalFuncs; // GeneralFunction2
+ std::vector<ScGeneralFunction> maSubTotalFuncs;
css::sheet::DataPilotFieldReference* pReferenceValue;
css::sheet::DataPilotFieldSortInfo* pSortInfo; // (level)
css::sheet::DataPilotFieldAutoShowInfo* pAutoShowInfo; // (level)
@@ -145,11 +146,11 @@ public:
void SetName( const OUString& rNew ); // used if the source dim was renamed (groups)
void SetOrientation(sal_uInt16 nNew);
- void SetSubTotals(std::vector<sal_uInt16> const & rFuncs);
+ void SetSubTotals(std::vector<ScGeneralFunction> const & rFuncs);
long GetSubTotalsCount() const
{ return maSubTotalFuncs.size(); }
- sal_uInt16 GetSubTotalFunc(long nIndex) const
+ ScGeneralFunction GetSubTotalFunc(long nIndex) const
{ return maSubTotalFuncs[nIndex]; }
bool HasShowEmpty() const;
@@ -161,8 +162,8 @@ public:
bool GetRepeatItemLabels() const
{ return bRepeatItemLabels; }
- void SetFunction(sal_uInt16 nNew); // enum GeneralFunction
- sal_uInt16 GetFunction() const
+ void SetFunction(ScGeneralFunction nNew);
+ ScGeneralFunction GetFunction() const
{ return nFunction; }
void SetUsedHierarchy(long nNew);
diff --git a/sc/inc/dptabsrc.hxx b/sc/inc/dptabsrc.hxx
index 2cb65bae2617..9ee1a8e6ed80 100644
--- a/sc/inc/dptabsrc.hxx
+++ b/sc/inc/dptabsrc.hxx
@@ -65,9 +65,6 @@ class ScDPResultMember;
class ScDPResultData;
class ScDPItemData;
class ScDPTableData;
-
-// implementation of DataPilotSource using ScDPTableData
-
class ScDPDimensions;
class ScDPDimension;
class ScDPHierarchies;
@@ -76,6 +73,9 @@ class ScDPLevels;
class ScDPLevel;
class ScDPMembers;
class ScDPMember;
+enum class ScGeneralFunction;
+
+// implementation of DataPilotSource using ScDPTableData
class ScDPSource : public cppu::WeakImplHelper<
css::sheet::XDimensionsSupplier,
@@ -267,7 +267,7 @@ class ScDPDimension : public cppu::WeakImplHelper<
ScDPSource* pSource;
long nDim; // dimension index (== column ID)
rtl::Reference<ScDPHierarchies> mxHierarchies;
- sal_uInt16 nFunction; // enum GeneralFunction2
+ ScGeneralFunction nFunction;
OUString aName; // if empty, take from source
std::unique_ptr<OUString> mpLayoutName;
std::unique_ptr<OUString> mpSubtotalName;
@@ -331,8 +331,8 @@ public:
sal_uInt16 getOrientation() const;
bool getIsDataLayoutDimension() const;
- sal_uInt16 getFunction() const { return nFunction;}
- void setFunction(sal_uInt16 nNew); // for data dimension
+ ScGeneralFunction getFunction() const { return nFunction;}
+ void setFunction(ScGeneralFunction nNew); // for data dimension
static long getUsedHierarchy() { return 0;}
bool HasSelectedPage() const { return bHasSelectedPage; }
diff --git a/sc/inc/dputil.hxx b/sc/inc/dputil.hxx
index 525e67363c9a..aec2b19e9c10 100644
--- a/sc/inc/dputil.hxx
+++ b/sc/inc/dputil.hxx
@@ -18,6 +18,7 @@
class SvNumberFormatter;
struct ScDPNumGroupInfo;
+enum class ScGeneralFunction;
class ScDPUtil
{
@@ -50,8 +51,7 @@ public:
static OUString getDisplayedMeasureName(const OUString& rName, ScSubTotalFunc eFunc);
- static ScSubTotalFunc toSubTotalFunc(css::sheet::GeneralFunction eGenFunc);
- static ScSubTotalFunc toSubTotalFunc(sal_Int16 eGenFunc);
+ static ScSubTotalFunc toSubTotalFunc(ScGeneralFunction eGenFunc);
};
#endif
diff --git a/sc/inc/generalfunction.hxx b/sc/inc/generalfunction.hxx
new file mode 100644
index 000000000000..0716f83e66d5
--- /dev/null
+++ b/sc/inc/generalfunction.hxx
@@ -0,0 +1,104 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SC_SHEET_GENERAL_FUNCTION_HXX
+#define INCLUDED_SC_SHEET_GENERAL_FUNCTION_HXX
+
+#include <com/sun/star/sheet/GeneralFunction.hpp>
+#include <com/sun/star/sheet/GeneralFunction2.hpp>
+
+/**
+ * the css::sheet::GeneralFunction enum is extended by constants in GeneralFunction2, which causes some type-safety issues.
+ * So abstract them behind the facade of this enum.
+ */
+enum class ScGeneralFunction
+{
+ /** nothing is calculated.
+ */
+ NONE = css::sheet::GeneralFunction_NONE,
+
+
+ /** function is determined automatically.
+
+ <p>If the values are all numerical, SUM is used, otherwise COUNT.</p>
+ */
+ AUTO = css::sheet::GeneralFunction_AUTO,
+
+
+ /** sum of all numerical values is calculated.
+ */
+ SUM = css::sheet::GeneralFunction_SUM,
+
+
+ /** all values, including non-numerical values, are counted.
+ */
+ COUNT = css::sheet::GeneralFunction_COUNT,
+
+
+ /** average of all numerical values is calculated.
+ */
+ AVERAGE = css::sheet::GeneralFunction_AVERAGE,
+
+
+ /** maximum value of all numerical values is calculated.
+ */
+ MAX = css::sheet::GeneralFunction_MAX,
+
+
+ /** minimum value of all numerical values is calculated.
+ */
+ MIN = css::sheet::GeneralFunction_MIN,
+
+
+ /** product of all numerical values is calculated.
+ */
+ PRODUCT = css::sheet::GeneralFunction_PRODUCT,
+
+
+ /** numerical values are counted.
+ */
+ COUNTNUMS = css::sheet::GeneralFunction_COUNTNUMS,
+
+
+ /** standard deviation is calculated based on a sample.
+ */
+ STDEV = css::sheet::GeneralFunction_STDEV,
+
+
+ /** standard deviation is calculated based on the entire population.
+ */
+ STDEVP = css::sheet::GeneralFunction_STDEVP,
+
+
+ /** variance is calculated based on a sample.
+ */
+ VAR = css::sheet::GeneralFunction_VAR,
+
+
+ /** variance is calculated based on the entire population.
+ */
+ VARP = css::sheet::GeneralFunction_VARP,
+
+ /**
+ * median of all numerical values is calculated.
+ * @since LibreOffice 5.3
+ */
+ MEDIAN = css::sheet::GeneralFunction2::MEDIAN
+};
+
+#endif
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index fbb16cd9748c..ae588cc461bc 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -34,6 +34,7 @@
#include "scopetools.hxx"
#include "cellvalue.hxx"
#include "docfunc.hxx"
+#include "generalfunction.hxx"
#include <postit.hxx>
#include <tokenstringcontext.hxx>
#include <chgtrack.hxx>
@@ -2880,7 +2881,7 @@ void ScExportTest::testPivotTableXLSX()
}
const ScDPSaveDimension* pDim = aDims[0];
- if (pDim->GetFunction() != sheet::GeneralFunction2::SUM)
+ if (pDim->GetFunction() != ScGeneralFunction::SUM)
{
cerr << "Data field should have SUM function." << endl;
return false;
@@ -2987,13 +2988,13 @@ void ScExportTest::testPivotTableTwoDataFieldsXLSX()
return false;
}
- if (aDims[0]->GetFunction() != sheet::GeneralFunction2::SUM)
+ if (aDims[0]->GetFunction() != ScGeneralFunction::SUM)
{
cerr << "First data field should be SUM." << endl;
return false;
}
- if (aDims[1]->GetFunction() != sheet::GeneralFunction2::COUNT)
+ if (aDims[1]->GetFunction() != ScGeneralFunction::COUNT)
{
cerr << "First data field should be COUNT." << endl;
return false;
@@ -3063,7 +3064,7 @@ void ScExportTest::testPivotTableMedianODS()
const ScDPSaveDimension* pDim = aDims.back();
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Function for the data field should be MEDIAN.",
- sal_uInt16(sheet::GeneralFunction2::MEDIAN), pDim->GetFunction());
+ sal_uInt16(ScGeneralFunction::MEDIAN), sal_uInt16(pDim->GetFunction()));
xDocSh2->DoClose();
}
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index b2d262dfd0ac..a13964349f89 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -71,6 +71,7 @@
#include "orcusfilters.hxx"
#include "filter.hxx"
#include "orcusinterface.hxx"
+#include "generalfunction.hxx"
#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
#include <com/sun/star/drawing/XControlShape.hpp>
@@ -1853,7 +1854,7 @@ void ScFiltersTest::testPivotTableBasicODS()
const ScDPSaveDimension* pDim = aDims.back();
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Function for the data field should be COUNT.",
- sal_uInt16(sheet::GeneralFunction2::COUNT), pDim->GetFunction());
+ sal_uInt16(ScGeneralFunction::COUNT), sal_uInt16(pDim->GetFunction()));
xDocSh->DoClose();
}
diff --git a/sc/qa/unit/ucalc_pivottable.cxx b/sc/qa/unit/ucalc_pivottable.cxx
index b2ca97a06774..28b6835221e9 100644
--- a/sc/qa/unit/ucalc_pivottable.cxx
+++ b/sc/qa/unit/ucalc_pivottable.cxx
@@ -18,6 +18,7 @@
#include "queryentry.hxx"
#include "stringutil.hxx"
#include "dbdocfun.hxx"
+#include "generalfunction.hxx"
#include <formula/errorcodes.hxx>
#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
@@ -39,7 +40,7 @@ struct DPFieldDef
* Function for data field. It's used only for data field. When 0, the
* default function (SUM) is used.
*/
- int eFunc;
+ ScGeneralFunction eFunc;
bool bRepeatItemLabels;
};
@@ -113,9 +114,9 @@ ScDPObject* createDPFromSourceDesc(
if (aFields[i].eOrient == sheet::DataPilotFieldOrientation_DATA)
{
- sheet::GeneralFunction eFunc = sheet::GeneralFunction_SUM;
- if (aFields[i].eFunc)
- eFunc = static_cast<sheet::GeneralFunction>(aFields[i].eFunc);
+ ScGeneralFunction eFunc = ScGeneralFunction::SUM;
+ if (aFields[i].eFunc != ScGeneralFunction::NONE)
+ eFunc = aFields[i].eFunc;
pDim->SetFunction(eFunc);
pDim->SetReferenceValue(nullptr);
@@ -193,9 +194,9 @@ void Test::testPivotTable()
// Dimension definition
DPFieldDef aFields[] = {
- { "Name", sheet::DataPilotFieldOrientation_ROW, 0, false },
- { "Group", sheet::DataPilotFieldOrientation_COLUMN, 0, false },
- { "Score", sheet::DataPilotFieldOrientation_DATA, 0, false }
+ { "Name", sheet::DataPilotFieldOrientation_ROW, ScGeneralFunction::NONE, false },
+ { "Group", sheet::DataPilotFieldOrientation_COLUMN, ScGeneralFunction::NONE, false },
+ { "Score", sheet::DataPilotFieldOrientation_DATA, ScGeneralFunction::NONE, false }
};
// Raw data
@@ -377,9 +378,9 @@ void Test::testPivotTableLabels()
// Dimension definition
DPFieldDef aFields[] = {
- { "Software", sheet::DataPilotFieldOrientation_ROW, 0, false },
- { "Version", sheet::DataPilotFieldOrientation_COLUMN, 0, false },
- { "1.2.3", sheet::DataPilotFieldOrientation_DATA, 0, false }
+ { "Software", sheet::DataPilotFieldOrientation_ROW, ScGeneralFunction::NONE, false },
+ { "Version", sheet::DataPilotFieldOrientation_COLUMN, ScGeneralFunction::NONE, false },
+ { "1.2.3", sheet::DataPilotFieldOrientation_DATA, ScGeneralFunction::NONE, false }
};
// Raw data
@@ -433,9 +434,9 @@ void Test::testPivotTableDateLabels()
// Dimension definition
DPFieldDef aFields[] = {
- { "Name", sheet::DataPilotFieldOrientation_ROW, 0, false },
- { "Date", sheet::DataPilotFieldOrientation_COLUMN, 0, false },
- { "Value", sheet::DataPilotFieldOrientation_DATA, 0, false }
+ { "Name", sheet::DataPilotFieldOrientation_ROW, ScGeneralFunction::NONE, false },
+ { "Date", sheet::DataPilotFieldOrientation_COLUMN, ScGeneralFunction::NONE, false },
+ { "Value", sheet::DataPilotFieldOrientation_DATA, ScGeneralFunction::NONE, false }
};
// Raw data
@@ -509,11 +510,11 @@ void Test::testPivotTableFilters()
// Dimension definition
DPFieldDef aFields[] = {
- { "Name", sheet::DataPilotFieldOrientation_HIDDEN, 0, false },
- { "Group1", sheet::DataPilotFieldOrientation_HIDDEN, 0, false },
- { "Group2", sheet::DataPilotFieldOrientation_PAGE, 0, false },
- { "Val1", sheet::DataPilotFieldOrientation_DATA, 0, false },
- { "Val2", sheet::DataPilotFieldOrientation_DATA, 0, false }
+ { "Name", sheet::DataPilotFieldOrientation_HIDDEN, ScGeneralFunction::NONE, false },
+ { "Group1", sheet::DataPilotFieldOrientation_HIDDEN, ScGeneralFunction::NONE, false },
+ { "Group2", sheet::DataPilotFieldOrientation_PAGE, ScGeneralFunction::NONE, false },
+ { "Val1", sheet::DataPilotFieldOrientation_DATA, ScGeneralFunction::NONE, false },
+ { "Val2", sheet::DataPilotFieldOrientation_DATA, ScGeneralFunction::NONE, false }
};
// Raw data
@@ -662,9 +663,9 @@ void Test::testPivotTableNamedSource()
// Dimension definition
DPFieldDef aFields[] = {
- { "Name", sheet::DataPilotFieldOrientation_ROW, 0, false },
- { "Group", sheet::DataPilotFieldOrientation_COLUMN, 0, false },
- { "Score", sheet::DataPilotFieldOrientation_DATA, 0, false }
+ { "Name", sheet::DataPilotFieldOrientation_ROW, ScGeneralFunction::NONE, false },
+ { "Group", sheet::DataPilotFieldOrientation_COLUMN, ScGeneralFunction::NONE, false },
+ { "Score", sheet::DataPilotFieldOrientation_DATA, ScGeneralFunction::NONE, false }
};
// Raw data
@@ -962,9 +963,9 @@ void Test::testPivotTableDuplicateDataFields()
// Dimension definition
DPFieldDef aFields[] = {
- { "Name", sheet::DataPilotFieldOrientation_ROW, 0, false },
- { "Value", sheet::DataPilotFieldOrientation_DATA, sheet::GeneralFunction_SUM, false },
- { "Value", sheet::DataPilotFieldOrientation_DATA, sheet::GeneralFunction_COUNT, false }
+ { "Name", sheet::DataPilotFieldOrientation_ROW, ScGeneralFunction::NONE, false },
+ { "Value", sheet::DataPilotFieldOrientation_DATA, ScGeneralFunction::SUM, false },
+ { "Value", sheet::DataPilotFieldOrientation_DATA, ScGeneralFunction::COUNT, false }
};
ScAddress aPos(2,2,0);
@@ -1056,8 +1057,8 @@ void Test::testPivotTableNormalGrouping()
// Dimension definition
DPFieldDef aFields[] = {
- { "Name", sheet::DataPilotFieldOrientation_ROW, 0, false },
- { "Value", sheet::DataPilotFieldOrientation_DATA, sheet::GeneralFunction_SUM, false },
+ { "Name", sheet::DataPilotFieldOrientation_ROW, ScGeneralFunction::NONE, false },
+ { "Value", sheet::DataPilotFieldOrientation_DATA, ScGeneralFunction::SUM, false },
};
ScAddress aPos(1,1,0);
@@ -1218,8 +1219,8 @@ void Test::testPivotTableNumberGrouping()
// Dimension definition
DPFieldDef aFields[] = {
- { "Order", sheet::DataPilotFieldOrientation_ROW, 0, false },
- { "Score", sheet::DataPilotFieldOrientation_DATA, sheet::GeneralFunction_SUM, false },
+ { "Order", sheet::DataPilotFieldOrientation_ROW, ScGeneralFunction::NONE, false },
+ { "Score", sheet::DataPilotFieldOrientation_DATA, ScGeneralFunction::SUM, false },
};
ScAddress aPos(1,1,0);
@@ -1303,8 +1304,8 @@ void Test::testPivotTableDateGrouping()
// Dimension definition
DPFieldDef aFields[] = {
- { "Date", sheet::DataPilotFieldOrientation_ROW, 0, false },
- { "Value", sheet::DataPilotFieldOrientation_DATA, sheet::GeneralFunction_SUM, false },
+ { "Date", sheet::DataPilotFieldOrientation_ROW, ScGeneralFunction::NONE, false },
+ { "Value", sheet::DataPilotFieldOrientation_DATA, ScGeneralFunction::SUM, false },
};
ScAddress aPos(1,1,0);
@@ -1473,8 +1474,8 @@ void Test::testPivotTableEmptyRows()
// Dimension definition
DPFieldDef aFields[] = {
- { "Name", sheet::DataPilotFieldOrientation_ROW, 0, false },
- { "Value", sheet::DataPilotFieldOrientation_DATA, sheet::GeneralFunction_SUM, false },
+ { "Name", sheet::DataPilotFieldOrientation_ROW, ScGeneralFunction::NONE, false },
+ { "Value", sheet::DataPilotFieldOrientation_DATA, ScGeneralFunction::SUM, false },
};
ScAddress aPos(1,1,0);
@@ -1586,8 +1587,8 @@ void Test::testPivotTableTextNumber()
// Dimension definition
DPFieldDef aFields[] = {
- { "Name", sheet::DataPilotFieldOrientation_ROW, 0, false },
- { "Value", sheet::DataPilotFieldOrientation_DATA, sheet::GeneralFunction_SUM, false },
+ { "Name", sheet::DataPilotFieldOrientation_ROW, ScGeneralFunction::NONE, false },
+ { "Value", sheet::DataPilotFieldOrientation_DATA, ScGeneralFunction::SUM, false },
};
// Insert raw data such that the first column values are entered as text.
@@ -1688,8 +1689,8 @@ void Test::testPivotTableCaseInsensitiveStrings()
// Dimension definition
DPFieldDef aFields[] = {
- { "Name", sheet::DataPilotFieldOrientation_ROW, 0, false },
- { "Value", sheet::DataPilotFieldOrientation_DATA, sheet::GeneralFunction_SUM, false },
+ { "Name", sheet::DataPilotFieldOrientation_ROW, ScGeneralFunction::NONE, false },
+ { "Value", sheet::DataPilotFieldOrientation_DATA, ScGeneralFunction::SUM, false },
};
ScAddress aPos(1,1,0);
@@ -1764,8 +1765,8 @@ void Test::testPivotTableNumStability()
// Dimension definition
DPFieldDef aFields[] = {
- { "Name", sheet::DataPilotFieldOrientation_ROW, 0, false },
- { "Total", sheet::DataPilotFieldOrientation_DATA, sheet::GeneralFunction_SUM, false },
+ { "Name", sheet::DataPilotFieldOrientation_ROW, ScGeneralFunction::NONE, false },
+ { "Total", sheet::DataPilotFieldOrientation_DATA, ScGeneralFunction::SUM, false },
};
m_pDoc->InsertTab(0, "Data");
@@ -1851,8 +1852,8 @@ void Test::testPivotTableFieldReference()
// Dimension definition
DPFieldDef aFields[] = {
- { "Name", sheet::DataPilotFieldOrientation_ROW, 0, false },
- { "Value", sheet::DataPilotFieldOrientation_DATA, sheet::GeneralFunction_SUM, false },
+ { "Name", sheet::DataPilotFieldOrientation_ROW, ScGeneralFunction::NONE, false },
+ { "Value", sheet::DataPilotFieldOrientation_DATA, ScGeneralFunction::SUM, false },
};
ScAddress aPos(1,1,0);
@@ -2021,8 +2022,8 @@ void Test::testPivotTableDocFunc()
// Dimension definition
DPFieldDef aFields[] = {
- { "Name", sheet::DataPilotFieldOrientation_ROW, 0, false },
- { "Value", sheet::DataPilotFieldOrientation_DATA, sheet::GeneralFunction_SUM, false },
+ { "Name", sheet::DataPilotFieldOrientation_ROW, ScGeneralFunction::NONE, false },
+ { "Value", sheet::DataPilotFieldOrientation_DATA, ScGeneralFunction::SUM, false },
};
ScAddress aPos(1,1,0);
@@ -2096,8 +2097,8 @@ void Test::testFuncGETPIVOTDATA()
{
// Dimension definition
DPFieldDef aFields[] = {
- { "Name", sheet::DataPilotFieldOrientation_ROW, 0, false },
- { "Value", sheet::DataPilotFieldOrientation_DATA, sheet::GeneralFunction_SUM, false },
+ { "Name", sheet::DataPilotFieldOrientation_ROW, ScGeneralFunction::NONE, false },
+ { "Value", sheet::DataPilotFieldOrientation_DATA, ScGeneralFunction::SUM, false },
};
pDPObj = createDPFromRange(m_pDoc, aDataRange, aFields, SAL_N_ELEMENTS(aFields), false);
@@ -2159,9 +2160,9 @@ void Test::testFuncGETPIVOTDATA()
{
// Dimension definition
DPFieldDef aFields[] = {
- { "Name", sheet::DataPilotFieldOrientation_ROW, 0, false },
- { "Value", sheet::DataPilotFieldOrientation_DATA, sheet::GeneralFunction_SUM, false },
- { "Value", sheet::DataPilotFieldOrientation_DATA, sheet::GeneralFunction_COUNT, false },
+ { "Name", sheet::DataPilotFieldOrientation_ROW, ScGeneralFunction::NONE, false },
+ { "Value", sheet::DataPilotFieldOrientation_DATA, ScGeneralFunction::SUM, false },
+ { "Value", sheet::DataPilotFieldOrientation_DATA, ScGeneralFunction::COUNT, false },
};
pDPObj = createDPFromRange(m_pDoc, aDataRange, aFields, SAL_N_ELEMENTS(aFields), false);
@@ -2254,9 +2255,9 @@ void Test::testFuncGETPIVOTDATALeafAccess()
// Dimension definition
DPFieldDef aFields[] = {
- { "Type", sheet::DataPilotFieldOrientation_ROW, 0, false },
- { "Member", sheet::DataPilotFieldOrientation_ROW, 0, false },
- { "Value", sheet::DataPilotFieldOrientation_DATA, sheet::GeneralFunction_SUM, false },
+ { "Type", sheet::DataPilotFieldOrientation_ROW, ScGeneralFunction::NONE, false },
+ { "Member", sheet::DataPilotFieldOrientation_ROW, ScGeneralFunction::NONE, false },
+ { "Value", sheet::DataPilotFieldOrientation_DATA, ScGeneralFunction::SUM, false },
};
// Create pivot table at A1 on 2nd sheet.
@@ -2331,10 +2332,10 @@ void Test::testPivotTableRepeatItemLabels()
// Dimension definition
DPFieldDef aFields[] = {
- { "Name", sheet::DataPilotFieldOrientation_ROW, 0, true },
- { "Country", sheet::DataPilotFieldOrientation_ROW, 0, false },
- { "Year", sheet::DataPilotFieldOrientation_ROW, 0, false },
- { "Score", sheet::DataPilotFieldOrientation_DATA, 0, false }
+ { "Name", sheet::DataPilotFieldOrientation_ROW, ScGeneralFunction::NONE, true },
+ { "Country", sheet::DataPilotFieldOrientation_ROW, ScGeneralFunction::NONE, false },
+ { "Year", sheet::DataPilotFieldOrientation_ROW, ScGeneralFunction::NONE, false },
+ { "Score", sheet::DataPilotFieldOrientation_DATA, ScGeneralFunction::NONE, false }
};
// Raw data
@@ -2409,9 +2410,9 @@ void Test::testPivotTableDPCollection()
// Dimension definition
DPFieldDef aFields[] = {
- { "Software", sheet::DataPilotFieldOrientation_ROW, 0, false },
- { "Version", sheet::DataPilotFieldOrientation_COLUMN, 0, false },
- { "1.2.3", sheet::DataPilotFieldOrientation_DATA, 0, false }
+ { "Software", sheet::DataPilotFieldOrientation_ROW, ScGeneralFunction::NONE, false },
+ { "Version", sheet::DataPilotFieldOrientation_COLUMN, ScGeneralFunction::NONE, false },
+ { "1.2.3", sheet::DataPilotFieldOrientation_DATA, ScGeneralFunction::NONE, false }
};
// Raw data
@@ -2520,10 +2521,10 @@ void Test::testPivotTableMedianFunc()
// Dimension definition
DPFieldDef aFields[] = {
- { "Condition", sheet::DataPilotFieldOrientation_ROW, 0, false },
- { "Day1Hit", sheet::DataPilotFieldOrientation_DATA, sheet::GeneralFunction2::MEDIAN, false },
- { "Day1Miss", sheet::DataPilotFieldOrientation_DATA, sheet::GeneralFunction2::MEDIAN, false },
- { "Day1FalseAlarm", sheet::DataPilotFieldOrientation_DATA, sheet::GeneralFunction2::MEDIAN, false },
+ { "Condition", sheet::DataPilotFieldOrientation_ROW, ScGeneralFunction::NONE, false },
+ { "Day1Hit", sheet::DataPilotFieldOrientation_DATA, ScGeneralFunction::MEDIAN, false },
+ { "Day1Miss", sheet::DataPilotFieldOrientation_DATA, ScGeneralFunction::MEDIAN, false },
+ { "Day1FalseAlarm", sheet::DataPilotFieldOrientation_DATA, ScGeneralFunction::MEDIAN, false },
};
ScAddress aPos(1, 1, 0);
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 9b7c6e2bdb26..1e315bf75d36 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -1336,7 +1336,7 @@ public:
if (pLayoutName && ScGlobal::pCharClass->uppercase(*pLayoutName) == maName)
return true;
- sal_Int16 eGenFunc = pDim->GetFunction();
+ ScGeneralFunction eGenFunc = pDim->GetFunction();
ScSubTotalFunc eFunc = ScDPUtil::toSubTotalFunc(eGenFunc);
OUString aSrcName = ScDPUtil::getSourceDimensionName(pDim->GetName());
OUString aFuncName = ScDPUtil::getDisplayedMeasureName(aSrcName, eFunc);
@@ -2684,11 +2684,11 @@ void ScDPObject::ConvertOrientation(
bFirst = std::none_of(itrBeg, itr, FindByOriginalDim(nCol));
}
- sal_Int16 eFunc = ScDataPilotConversion::FirstFunc(rField.nFuncMask);
+ ScGeneralFunction eFunc = ScDataPilotConversion::FirstFunc(rField.nFuncMask);
if (!bFirst)
pDim = rSaveData.DuplicateDimension(pDim->GetName());
pDim->SetOrientation(nOrient);
- pDim->SetFunction(sal::static_int_cast<sal_uInt16>(eFunc));
+ pDim->SetFunction(eFunc);
if( rFieldRef.ReferenceType == sheet::DataPilotFieldReferenceType::NONE )
pDim->SetReferenceValue(nullptr);
@@ -2699,13 +2699,13 @@ void ScDPObject::ConvertOrientation(
{
pDim->SetOrientation( nOrient );
- std::vector<sal_uInt16> nSubTotalFuncs;
+ std::vector<ScGeneralFunction> nSubTotalFuncs;
nSubTotalFuncs.reserve(16);
sal_uInt16 nMask = 1;
for (sal_uInt16 nBit=0; nBit<16; nBit++)
{
if ( nFuncs & (PivotFunc)nMask )
- nSubTotalFuncs.push_back( sal::static_int_cast<sal_uInt16>(ScDataPilotConversion::FirstFunc( (PivotFunc)nMask )) );
+ nSubTotalFuncs.push_back( ScDataPilotConversion::FirstFunc( (PivotFunc)nMask ) );
nMask *= 2;
}
pDim->SetSubTotals( nSubTotalFuncs );
diff --git a/sc/source/core/data/dpsave.cxx b/sc/source/core/data/dpsave.cxx
index 1a77c814c819..ebfae9436692 100644
--- a/sc/source/core/data/dpsave.cxx
+++ b/sc/source/core/data/dpsave.cxx
@@ -25,6 +25,7 @@
#include "global.hxx"
#include "dptabsrc.hxx"
#include "dputil.hxx"
+#include "generalfunction.hxx"
#include <sal/types.h>
#include <osl/diagnose.h>
@@ -196,7 +197,7 @@ ScDPSaveDimension::ScDPSaveDimension(const OUString& rName, bool bDataLayout) :
bIsDataLayout( bDataLayout ),
bDupFlag( false ),
nOrientation( sheet::DataPilotFieldOrientation_HIDDEN ),
- nFunction( sheet::GeneralFunction2::AUTO ),
+ nFunction( ScGeneralFunction::AUTO ),
nUsedHierarchy( -1 ),
nShowEmptyMode( SC_DPSAVEMODE_DONTKNOW ),
bRepeatItemLabels( false ),
@@ -352,7 +353,7 @@ void ScDPSaveDimension::SetOrientation(sal_uInt16 nNew)
nOrientation = nNew;
}
-void ScDPSaveDimension::SetSubTotals(std::vector<sal_uInt16> const & rFuncs)
+void ScDPSaveDimension::SetSubTotals(std::vector<ScGeneralFunction> const & rFuncs)
{
maSubTotalFuncs = rFuncs;
bSubTotalDefault = false;
@@ -373,7 +374,7 @@ void ScDPSaveDimension::SetRepeatItemLabels(bool bSet)
bRepeatItemLabels = bSet;
}
-void ScDPSaveDimension::SetFunction(sal_uInt16 nNew)
+void ScDPSaveDimension::SetFunction(ScGeneralFunction nNew)
{
nFunction = nNew;
}
@@ -598,7 +599,9 @@ void ScDPSaveDimension::WriteToSource( const uno::Reference<uno::XInterface>& xD
{
if ( !bSubTotalDefault )
{
- uno::Sequence<sal_Int16> aSeq(comphelper::containerToSequence<sal_Int16>(maSubTotalFuncs));
+ uno::Sequence<sal_Int16> aSeq(maSubTotalFuncs.size());
+ for(size_t i = 0; i < maSubTotalFuncs.size(); ++i)
+ aSeq.getArray()[i] = (sal_Int16)maSubTotalFuncs[i];
xLevProp->setPropertyValue( SC_UNO_DP_SUBTOTAL2, uno::Any(aSeq) );
}
if ( nShowEmptyMode != SC_DPSAVEMODE_DONTKNOW )
diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx
index f6e7bbfaaa60..13d7705206aa 100644
--- a/sc/source/core/data/dptabres.cxx
+++ b/sc/source/core/data/dptabres.cxx
@@ -25,6 +25,7 @@
#include "subtotal.hxx"
#include "globstr.hrc"
#include "dpitemdata.hxx"
+#include "generalfunction.hxx"
#include "document.hxx"
#include "dpresfilter.hxx"
@@ -739,8 +740,8 @@ static ScSubTotalFunc lcl_GetForceFunc( const ScDPLevel* pLevel, long nFuncNo )
if ( nFuncNo >= 0 && nFuncNo < nSequence )
{
- sal_Int16 eUser = aSeq.getConstArray()[nFuncNo];
- if (eUser != sheet::GeneralFunction2::AUTO)
+ ScGeneralFunction eUser = (ScGeneralFunction)aSeq.getConstArray()[nFuncNo];
+ if (eUser != ScGeneralFunction::AUTO)
eRet = ScDPUtil::toSubTotalFunc(eUser);
}
}
diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx
index f17f689f5cff..1b650bfb8641 100644
--- a/sc/source/core/data/dptabsrc.cxx
+++ b/sc/source/core/data/dptabsrc.cxx
@@ -46,6 +46,7 @@
#include "dputil.hxx"
#include "dpresfilter.hxx"
#include "calcmacros.hxx"
+#include "generalfunction.hxx"
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
@@ -794,11 +795,11 @@ void ScDPSource::CreateRes_Impl()
// Get function for each data field.
long nDimIndex = *it;
ScDPDimension* pDim = GetDimensionsObject()->getByIndex(nDimIndex);
- sal_Int16 eUser = static_cast<sal_Int16>(pDim->getFunction());
- if (eUser == sheet::GeneralFunction2::AUTO)
+ ScGeneralFunction eUser = pDim->getFunction();
+ if (eUser == ScGeneralFunction::AUTO)
{
//TODO: test for numeric data
- eUser = sheet::GeneralFunction2::SUM;
+ eUser = ScGeneralFunction::SUM;
}
// Map UNO's enum to internal enum ScSubTotalFunc.
@@ -1306,7 +1307,7 @@ ScDPDimension* ScDPDimensions::getByIndex(long nIndex) const
ScDPDimension::ScDPDimension( ScDPSource* pSrc, long nD ) :
pSource( pSrc ),
nDim( nD ),
- nFunction( SUBTOTAL_FUNC_SUM ), // sum is default
+ nFunction( ScGeneralFunction::SUM ), // sum is default
mpLayoutName(nullptr),
mpSubtotalName(nullptr),
nSourceDim( -1 ),
@@ -1370,7 +1371,7 @@ bool ScDPDimension::getIsDataLayoutDimension() const
return pSource->GetData()->getIsDataLayoutDimension( nDim );
}
-void ScDPDimension::setFunction(sal_uInt16 nNew)
+void ScDPDimension::setFunction(ScGeneralFunction nNew)
{
nFunction = nNew;
}
@@ -1477,13 +1478,13 @@ void SAL_CALL ScDPDimension::setPropertyValue( const OUString& aPropertyName, co
{
sheet::GeneralFunction eEnum;
if (aValue >>= eEnum)
- setFunction( sal::static_int_cast<sal_uInt16>(eEnum) );
+ setFunction( (ScGeneralFunction)eEnum );
}
else if ( aPropertyName == SC_UNO_DP_FUNCTION2 )
{
sal_Int16 eEnum;
if (aValue >>= eEnum)
- setFunction( eEnum );
+ setFunction( (ScGeneralFunction)eEnum );
}
else if ( aPropertyName == SC_UNO_DP_REFVALUE )
aValue >>= aReferenceValue;
@@ -1557,22 +1558,15 @@ uno::Any SAL_CALL ScDPDimension::getPropertyValue( const OUString& aPropertyName
}
else if ( aPropertyName == SC_UNO_DP_FUNCTION )
{
- sheet::GeneralFunction eVal;
- sal_Int16 nVal = getFunction();
- if (nVal == sheet::GeneralFunction2::MEDIAN)
- {
- eVal = sheet::GeneralFunction_NONE;
- }
- else
- {
- eVal = static_cast<sheet::GeneralFunction>(getFunction());
- }
- aRet <<= eVal;
+ ScGeneralFunction nVal = getFunction();
+ if (nVal == ScGeneralFunction::MEDIAN)
+ nVal = ScGeneralFunction::NONE;
+ aRet <<= (sheet::GeneralFunction)nVal;
}
else if ( aPropertyName == SC_UNO_DP_FUNCTION2 )
{
- sal_Int16 eVal = getFunction();
- aRet <<= eVal;
+ ScGeneralFunction eVal = getFunction();
+ aRet <<= (sal_Int16)eVal;
}
else if ( aPropertyName == SC_UNO_DP_REFVALUE )
aRet <<= aReferenceValue;
@@ -1581,9 +1575,9 @@ uno::Any SAL_CALL ScDPDimension::getPropertyValue( const OUString& aPropertyName
else if ( aPropertyName == SC_UNO_DP_NUMBERFO )
{
sal_Int32 nFormat = 0;
- sal_Int16 eFunc = getFunction();
+ ScGeneralFunction eFunc = getFunction();
// #i63745# don't use source format for "count"
- if ( eFunc != sheet::GeneralFunction2::COUNT && eFunc != sheet::GeneralFunction2::COUNTNUMS )
+ if ( eFunc != ScGeneralFunction::COUNT && eFunc != ScGeneralFunction::COUNTNUMS )
nFormat = pSource->GetData()->GetNumberFormat( ( nSourceDim >= 0 ) ? nSourceDim : nDim );
switch ( aReferenceValue.ReferenceType )
diff --git a/sc/source/core/data/dputil.cxx b/sc/source/core/data/dputil.cxx
index c2c4e46b02ec..440ac8d4e0bc 100644
--- a/sc/source/core/data/dputil.cxx
+++ b/sc/source/core/data/dputil.cxx
@@ -12,6 +12,7 @@
#include "dpnumgroupinfo.hxx"
#include "globalnames.hxx"
#include "globstr.hrc"
+#include "generalfunction.hxx"
#include <comphelper/string.hxx>
#include <unotools/localedatawrapper.hxx>
@@ -402,49 +403,25 @@ OUString ScDPUtil::getDisplayedMeasureName(const OUString& rName, ScSubTotalFunc
return aRet.makeStringAndClear();
}
-ScSubTotalFunc ScDPUtil::toSubTotalFunc(css::sheet::GeneralFunction eGenFunc)
+ScSubTotalFunc ScDPUtil::toSubTotalFunc(ScGeneralFunction eGenFunc)
{
ScSubTotalFunc eSubTotal = SUBTOTAL_FUNC_NONE;
switch (eGenFunc)
{
- case sheet::GeneralFunction_NONE: eSubTotal = SUBTOTAL_FUNC_NONE; break;
- case sheet::GeneralFunction_SUM: eSubTotal = SUBTOTAL_FUNC_SUM; break;
- case sheet::GeneralFunction_COUNT: eSubTotal = SUBTOTAL_FUNC_CNT2; break;
- case sheet::GeneralFunction_AVERAGE: eSubTotal = SUBTOTAL_FUNC_AVE; break;
- case sheet::GeneralFunction_MAX: eSubTotal = SUBTOTAL_FUNC_MAX; break;
- case sheet::GeneralFunction_MIN: eSubTotal = SUBTOTAL_FUNC_MIN; break;
- case sheet::GeneralFunction_PRODUCT: eSubTotal = SUBTOTAL_FUNC_PROD; break;
- case sheet::GeneralFunction_COUNTNUMS: eSubTotal = SUBTOTAL_FUNC_CNT; break;
- case sheet::GeneralFunction_STDEV: eSubTotal = SUBTOTAL_FUNC_STD; break;
- case sheet::GeneralFunction_STDEVP: eSubTotal = SUBTOTAL_FUNC_STDP; break;
- case sheet::GeneralFunction_VAR: eSubTotal = SUBTOTAL_FUNC_VAR; break;
- case sheet::GeneralFunction_VARP: eSubTotal = SUBTOTAL_FUNC_VARP; break;
- case sheet::GeneralFunction_AUTO: eSubTotal = SUBTOTAL_FUNC_NONE; break;
- default:
- assert(false);
- }
- return eSubTotal;
-}
-
-ScSubTotalFunc ScDPUtil::toSubTotalFunc(sal_Int16 eGenFunc)
-{
- ScSubTotalFunc eSubTotal = SUBTOTAL_FUNC_NONE;
- switch (eGenFunc)
- {
- case sheet::GeneralFunction2::NONE: eSubTotal = SUBTOTAL_FUNC_NONE; break;
- case sheet::GeneralFunction2::SUM: eSubTotal = SUBTOTAL_FUNC_SUM; break;
- case sheet::GeneralFunction2::COUNT: eSubTotal = SUBTOTAL_FUNC_CNT2; break;
- case sheet::GeneralFunction2::AVERAGE: eSubTotal = SUBTOTAL_FUNC_AVE; break;
- case sheet::GeneralFunction2::MEDIAN: eSubTotal = SUBTOTAL_FUNC_MED; break;
- case sheet::GeneralFunction2::MAX: eSubTotal = SUBTOTAL_FUNC_MAX; break;
- case sheet::GeneralFunction2::MIN: eSubTotal = SUBTOTAL_FUNC_MIN; break;
- case sheet::GeneralFunction2::PRODUCT: eSubTotal = SUBTOTAL_FUNC_PROD; break;
- case sheet::GeneralFunction2::COUNTNUMS: eSubTotal = SUBTOTAL_FUNC_CNT; break;
- case sheet::GeneralFunction2::STDEV: eSubTotal = SUBTOTAL_FUNC_STD; break;
- case sheet::GeneralFunction2::STDEVP: eSubTotal = SUBTOTAL_FUNC_STDP; break;
- case sheet::GeneralFunction2::VAR: eSubTotal = SUBTOTAL_FUNC_VAR; break;
- case sheet::GeneralFunction2::VARP: eSubTotal = SUBTOTAL_FUNC_VARP; break;
- case sheet::GeneralFunction2::AUTO: eSubTotal = SUBTOTAL_FUNC_NONE; break;
+ case ScGeneralFunction::NONE: eSubTotal = SUBTOTAL_FUNC_NONE; break;
+ case ScGeneralFunction::SUM: eSubTotal = SUBTOTAL_FUNC_SUM; break;
+ case ScGeneralFunction::COUNT: eSubTotal = SUBTOTAL_FUNC_CNT2; break;
+ case ScGeneralFunction::AVERAGE: eSubTotal = SUBTOTAL_FUNC_AVE; break;
+ case ScGeneralFunction::MEDIAN: eSubTotal = SUBTOTAL_FUNC_MED; break;
+ case ScGeneralFunction::MAX: eSubTotal = SUBTOTAL_FUNC_MAX; break;
+ case ScGeneralFunction::MIN: eSubTotal = SUBTOTAL_FUNC_MIN; break;
+ case ScGeneralFunction::PRODUCT: eSubTotal = SUBTOTAL_FUNC_PROD; break;
+ case ScGeneralFunction::COUNTNUMS: eSubTotal = SUBTOTAL_FUNC_CNT; break;
+ case ScGeneralFunction::STDEV: eSubTotal = SUBTOTAL_FUNC_STD; break;
+ case ScGeneralFunction::STDEVP: eSubTotal = SUBTOTAL_FUNC_STDP; break;
+ case ScGeneralFunction::VAR: eSubTotal = SUBTOTAL_FUNC_VAR; break;
+ case ScGeneralFunction::VARP: eSubTotal = SUBTOTAL_FUNC_VARP; break;
+ case ScGeneralFunction::AUTO: eSubTotal = SUBTOTAL_FUNC_NONE; break;
default:
assert(false);
}
diff --git a/sc/source/filter/excel/xepivot.cxx b/sc/source/filter/excel/xepivot.cxx
index 568843df78e1..2015e8869927 100644
--- a/sc/source/filter/excel/xepivot.cxx
+++ b/sc/source/filter/excel/xepivot.cxx
@@ -41,6 +41,7 @@
#include "xestring.hxx"
#include "xelink.hxx"
#include "dputil.hxx"
+#include "generalfunction.hxx"
using namespace ::oox;
@@ -859,25 +860,24 @@ void XclExpPivotCache::WriteSxindexlistList( XclExpStream& rStrm ) const
namespace {
/** Returns a display string for a data field containing the field name and aggregation function. */
-OUString lclGetDataFieldCaption( const OUString& rFieldName, GeneralFunction eFunc )
+OUString lclGetDataFieldCaption( const OUString& rFieldName, ScGeneralFunction eFunc )
{
OUString aCaption;
sal_uInt16 nResIdx = 0;
- using namespace ::com::sun::star::sheet;
switch( eFunc )
{
- case GeneralFunction_SUM: nResIdx = STR_FUN_TEXT_SUM; break;
- case GeneralFunction_COUNT: nResIdx = STR_FUN_TEXT_COUNT; break;
- case GeneralFunction_AVERAGE: nResIdx = STR_FUN_TEXT_AVG; break;
- case GeneralFunction_MAX: nResIdx = STR_FUN_TEXT_MAX; break;
- case GeneralFunction_MIN: nResIdx = STR_FUN_TEXT_MIN; break;
- case GeneralFunction_PRODUCT: nResIdx = STR_FUN_TEXT_PRODUCT; break;
- case GeneralFunction_COUNTNUMS: nResIdx = STR_FUN_TEXT_COUNT; break;
- case GeneralFunction_STDEV: nResIdx = STR_FUN_TEXT_STDDEV; break;
- case GeneralFunction_STDEVP: nResIdx = STR_FUN_TEXT_STDDEV; break;
- case GeneralFunction_VAR: nResIdx = STR_FUN_TEXT_VAR; break;
- case GeneralFunction_VARP: nResIdx = STR_FUN_TEXT_VAR; break;
+ case ScGeneralFunction::SUM: nResIdx = STR_FUN_TEXT_SUM; break;
+ case ScGeneralFunction::COUNT: nResIdx = STR_FUN_TEXT_COUNT; break;
+ case ScGeneralFunction::AVERAGE: nResIdx = STR_FUN_TEXT_AVG; break;
+ case ScGeneralFunction::MAX: nResIdx = STR_FUN_TEXT_MAX; break;
+ case ScGeneralFunction::MIN: nResIdx = STR_FUN_TEXT_MIN; break;
+ case ScGeneralFunction::PRODUCT: nResIdx = STR_FUN_TEXT_PRODUCT; break;
+ case ScGeneralFunction::COUNTNUMS: nResIdx = STR_FUN_TEXT_COUNT; break;
+ case ScGeneralFunction::STDEV: nResIdx = STR_FUN_TEXT_STDDEV; break;
+ case ScGeneralFunction::STDEVP: nResIdx = STR_FUN_TEXT_STDDEV; break;
+ case ScGeneralFunction::VAR: nResIdx = STR_FUN_TEXT_VAR; break;
+ case ScGeneralFunction::VARP: nResIdx = STR_FUN_TEXT_VAR; break;
default:;
}
if( nResIdx )
@@ -1069,7 +1069,7 @@ void XclExpPTField::SetDataPropertiesFromDim( const ScDPSaveDimension& rSaveDim
maFieldInfo.AddApiOrient( DataPilotFieldOrientation_DATA );
// aggregation function
- GeneralFunction eFunc = static_cast< GeneralFunction >( rSaveDim.GetFunction() );
+ ScGeneralFunction eFunc = rSaveDim.GetFunction();
rDataInfo.SetApiAggFunc( eFunc );
// visible name
diff --git a/sc/source/filter/excel/xipivot.cxx b/sc/source/filter/excel/xipivot.cxx
index fc451bf173a2..23c72528a18f 100644
--- a/sc/source/filter/excel/xipivot.cxx
+++ b/sc/source/filter/excel/xipivot.cxx
@@ -1153,7 +1153,7 @@ void XclImpPTField::ConvertDataFieldInfo( ScDPSaveDimension& rSaveDim, const Xcl
rSaveDim.SetLayoutName(*pVisName);
// aggregation function
- rSaveDim.SetFunction( static_cast< sal_uInt16 >( rDataInfo.GetApiAggFunc() ) );
+ rSaveDim.SetFunction( rDataInfo.GetApiAggFunc() );
// result field reference
sal_Int32 nRefType = rDataInfo.GetApiRefType();
diff --git a/sc/source/filter/excel/xlpivot.cxx b/sc/source/filter/excel/xlpivot.cxx
index 2629138b8ec3..dbd5822d008c 100644
--- a/sc/source/filter/excel/xlpivot.cxx
+++ b/sc/source/filter/excel/xlpivot.cxx
@@ -23,6 +23,7 @@
#include "xistream.hxx"
#include "xestring.hxx"
#include "xlpivot.hxx"
+#include "generalfunction.hxx"
#include <osl/diagnose.h>
#include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp>
@@ -494,41 +495,40 @@ void XclPTFieldInfo::GetSubtotals( XclPTSubtotalVec& rSubtotals ) const
rSubtotals.clear();
rSubtotals.reserve( 16 );
- using namespace ::com::sun::star::sheet;
- if( mnSubtotals & EXC_SXVD_SUBT_DEFAULT ) rSubtotals.push_back( GeneralFunction_AUTO );
- if( mnSubtotals & EXC_SXVD_SUBT_SUM ) rSubtotals.push_back( GeneralFunction_SUM );
- if( mnSubtotals & EXC_SXVD_SUBT_COUNT ) rSubtotals.push_back( GeneralFunction_COUNT );
- if( mnSubtotals & EXC_SXVD_SUBT_AVERAGE ) rSubtotals.push_back( GeneralFunction_AVERAGE );
- if( mnSubtotals & EXC_SXVD_SUBT_MAX ) rSubtotals.push_back( GeneralFunction_MAX );
- if( mnSubtotals & EXC_SXVD_SUBT_MIN ) rSubtotals.push_back( GeneralFunction_MIN );
- if( mnSubtotals & EXC_SXVD_SUBT_PROD ) rSubtotals.push_back( GeneralFunction_PRODUCT );
- if( mnSubtotals & EXC_SXVD_SUBT_COUNTNUM ) rSubtotals.push_back( GeneralFunction_COUNTNUMS );
- if( mnSubtotals & EXC_SXVD_SUBT_STDDEV ) rSubtotals.push_back( GeneralFunction_STDEV );
- if( mnSubtotals & EXC_SXVD_SUBT_STDDEVP ) rSubtotals.push_back( GeneralFunction_STDEVP );
- if( mnSubtotals & EXC_SXVD_SUBT_VAR ) rSubtotals.push_back( GeneralFunction_VAR );
- if( mnSubtotals & EXC_SXVD_SUBT_VARP ) rSubtotals.push_back( GeneralFunction_VARP );
+ if( mnSubtotals & EXC_SXVD_SUBT_DEFAULT ) rSubtotals.push_back( ScGeneralFunction::AUTO );
+ if( mnSubtotals & EXC_SXVD_SUBT_SUM ) rSubtotals.push_back( ScGeneralFunction::SUM );
+ if( mnSubtotals & EXC_SXVD_SUBT_COUNT ) rSubtotals.push_back( ScGeneralFunction::COUNT );
+ if( mnSubtotals & EXC_SXVD_SUBT_AVERAGE ) rSubtotals.push_back( ScGeneralFunction::AVERAGE );
+ if( mnSubtotals & EXC_SXVD_SUBT_MAX ) rSubtotals.push_back( ScGeneralFunction::MAX );
+ if( mnSubtotals & EXC_SXVD_SUBT_MIN ) rSubtotals.push_back( ScGeneralFunction::MIN );
+ if( mnSubtotals & EXC_SXVD_SUBT_PROD ) rSubtotals.push_back( ScGeneralFunction::PRODUCT );
+ if( mnSubtotals & EXC_SXVD_SUBT_COUNTNUM ) rSubtotals.push_back( ScGeneralFunction::COUNTNUMS );
+ if( mnSubtotals & EXC_SXVD_SUBT_STDDEV ) rSubtotals.push_back( ScGeneralFunction::STDEV );
+ if( mnSubtotals & EXC_SXVD_SUBT_STDDEVP ) rSubtotals.push_back( ScGeneralFunction::STDEVP );
+ if( mnSubtotals & EXC_SXVD_SUBT_VAR ) rSubtotals.push_back( ScGeneralFunction::VAR );
+ if( mnSubtotals & EXC_SXVD_SUBT_VARP ) rSubtotals.push_back( ScGeneralFunction::VARP );
}
void XclPTFieldInfo::SetSubtotals( const XclPTSubtotalVec& rSubtotals )
{
mnSubtotals = EXC_SXVD_SUBT_NONE;
- using namespace ::com::sun::star::sheet;
for( XclPTSubtotalVec::const_iterator aIt = rSubtotals.begin(), aEnd = rSubtotals.end(); aIt != aEnd; ++aIt )
{
switch( *aIt )
{
- case GeneralFunction_AUTO: mnSubtotals |= EXC_SXVD_SUBT_DEFAULT; break;
- case GeneralFunction_SUM: mnSubtotals |= EXC_SXVD_SUBT_SUM; break;
- case GeneralFunction_COUNT: mnSubtotals |= EXC_SXVD_SUBT_COUNT; break;
- case GeneralFunction_AVERAGE: mnSubtotals |= EXC_SXVD_SUBT_AVERAGE; break;
- case GeneralFunction_MAX: mnSubtotals |= EXC_SXVD_SUBT_MAX; break;
- case GeneralFunction_MIN: mnSubtotals |= EXC_SXVD_SUBT_MIN; break;
- case GeneralFunction_PRODUCT: mnSubtotals |= EXC_SXVD_SUBT_PROD; break;
- case GeneralFunction_COUNTNUMS: mnSubtotals |= EXC_SXVD_SUBT_COUNTNUM; break;
- case GeneralFunction_STDEV: mnSubtotals |= EXC_SXVD_SUBT_STDDEV; break;
- case GeneralFunction_STDEVP: mnSubtotals |= EXC_SXVD_SUBT_STDDEVP; break;
- case GeneralFunction_VAR: mnSubtotals |= EXC_SXVD_SUBT_VAR; break;
- case GeneralFunction_VARP: mnSubtotals |= EXC_SXVD_SUBT_VARP; break;
+ case ScGeneralFunction::AUTO: mnSubtotals |= EXC_SXVD_SUBT_DEFAULT; break;
+ case ScGeneralFunction::SUM: mnSubtotals |= EXC_SXVD_SUBT_SUM; break;
+ case ScGeneralFunction::COUNT: mnSubtotals |= EXC_SXVD_SUBT_COUNT; break;
+ case ScGeneralFunction::AVERAGE: mnSubtotals |= EXC_SXVD_SUBT_AVERAGE; break;
+ case ScGeneralFunction::MAX: mnSubtotals |= EXC_SXVD_SUBT_MAX; break;
+ case ScGeneralFunction::MIN: mnSubtotals |= EXC_SXVD_SUBT_MIN; break;
+ case ScGeneralFunction::PRODUCT: mnSubtotals |= EXC_SXVD_SUBT_PROD; break;
+ case ScGeneralFunction::COUNTNUMS: mnSubtotals |= EXC_SXVD_SUBT_COUNTNUM; break;
+ case ScGeneralFunction::STDEV: mnSubtotals |= EXC_SXVD_SUBT_STDDEV; break;
+ case ScGeneralFunction::STDEVP: mnSubtotals |= EXC_SXVD_SUBT_STDDEVP; break;
+ case ScGeneralFunction::VAR: mnSubtotals |= EXC_SXVD_SUBT_VAR; break;
+ case ScGeneralFunction::VARP: mnSubtotals |= EXC_SXVD_SUBT_VARP; break;
+ default: break;
}
}
@@ -702,45 +702,43 @@ XclPTDataFieldInfo::XclPTDataFieldInfo() :
{
}
-GeneralFunction XclPTDataFieldInfo::GetApiAggFunc() const
+ScGeneralFunction XclPTDataFieldInfo::GetApiAggFunc() const
{
- using namespace ::com::sun::star::sheet;
- GeneralFunction eAggFunc;
+ ScGeneralFunction eAggFunc;
switch( mnAggFunc )
{
- case EXC_SXDI_FUNC_SUM: eAggFunc = GeneralFunction_SUM; break;
- case EXC_SXDI_FUNC_COUNT: eAggFunc = GeneralFunction_COUNT; break;
- case EXC_SXDI_FUNC_AVERAGE: eAggFunc = GeneralFunction_AVERAGE; break;
- case EXC_SXDI_FUNC_MAX: eAggFunc = GeneralFunction_MAX; break;
- case EXC_SXDI_FUNC_MIN: eAggFunc = GeneralFunction_MIN; break;
- case EXC_SXDI_FUNC_PRODUCT: eAggFunc = GeneralFunction_PRODUCT; break;
- case EXC_SXDI_FUNC_COUNTNUM: eAggFunc = GeneralFunction_COUNTNUMS; break;
- case EXC_SXDI_FUNC_STDDEV: eAggFunc = GeneralFunction_STDEV; break;
- case EXC_SXDI_FUNC_STDDEVP: eAggFunc = GeneralFunction_STDEVP; break;
- case EXC_SXDI_FUNC_VAR: eAggFunc = GeneralFunction_VAR; break;
- case EXC_SXDI_FUNC_VARP: eAggFunc = GeneralFunction_VARP; break;
- default: eAggFunc = GeneralFunction_SUM;
+ case EXC_SXDI_FUNC_SUM: eAggFunc = ScGeneralFunction::SUM; break;
+ case EXC_SXDI_FUNC_COUNT: eAggFunc = ScGeneralFunction::COUNT; break;
+ case EXC_SXDI_FUNC_AVERAGE: eAggFunc = ScGeneralFunction::AVERAGE; break;
+ case EXC_SXDI_FUNC_MAX: eAggFunc = ScGeneralFunction::MAX; break;
+ case EXC_SXDI_FUNC_MIN: eAggFunc = ScGeneralFunction::MIN; break;
+ case EXC_SXDI_FUNC_PRODUCT: eAggFunc = ScGeneralFunction::PRODUCT; break;
+ case EXC_SXDI_FUNC_COUNTNUM: eAggFunc = ScGeneralFunction::COUNTNUMS; break;
+ case EXC_SXDI_FUNC_STDDEV: eAggFunc = ScGeneralFunction::STDEV; break;
+ case EXC_SXDI_FUNC_STDDEVP: eAggFunc = ScGeneralFunction::STDEVP; break;
+ case EXC_SXDI_FUNC_VAR: eAggFunc = ScGeneralFunction::VAR; break;
+ case EXC_SXDI_FUNC_VARP: eAggFunc = ScGeneralFunction::VARP; break;
+ default: eAggFunc = ScGeneralFunction::SUM;
}
return eAggFunc;
}
-void XclPTDataFieldInfo::SetApiAggFunc( GeneralFunction eAggFunc )
+void XclPTDataFieldInfo::SetApiAggFunc( ScGeneralFunction eAggFunc )
{
- using namespace ::com::sun::star::sheet;
switch( eAggFunc )
{
- case GeneralFunction_SUM: mnAggFunc = EXC_SXDI_FUNC_SUM; break;
- case GeneralFunction_COUNT: mnAggFunc = EXC_SXDI_FUNC_COUNT; break;
- case GeneralFunction_AVERAGE: mnAggFunc = EXC_SXDI_FUNC_AVERAGE; break;
- case GeneralFunction_MAX: mnAggFunc = EXC_SXDI_FUNC_MAX; break;
- case GeneralFunction_MIN: mnAggFunc = EXC_SXDI_FUNC_MIN; break;
- case GeneralFunction_PRODUCT: mnAggFunc = EXC_SXDI_FUNC_PRODUCT; break;
- case GeneralFunction_COUNTNUMS: mnAggFunc = EXC_SXDI_FUNC_COUNTNUM; break;
- case GeneralFunction_STDEV: mnAggFunc = EXC_SXDI_FUNC_STDDEV; break;
- case GeneralFunction_STDEVP: mnAggFunc = EXC_SXDI_FUNC_STDDEVP; break;
- case GeneralFunction_VAR: mnAggFunc = EXC_SXDI_FUNC_VAR; break;
- case GeneralFunction_VARP: mnAggFunc = EXC_SXDI_FUNC_VARP; break;
- default: mnAggFunc = EXC_SXDI_FUNC_SUM;
+ case ScGeneralFunction::SUM: mnAggFunc = EXC_SXDI_FUNC_SUM; break;
+ case ScGeneralFunction::COUNT: mnAggFunc = EXC_SXDI_FUNC_COUNT; break;
+ case ScGeneralFunction::AVERAGE: mnAggFunc = EXC_SXDI_FUNC_AVERAGE; break;
+ case ScGeneralFunction::MAX: mnAggFunc = EXC_SXDI_FUNC_MAX; break;
+ case ScGeneralFunction::MIN: mnAggFunc = EXC_SXDI_FUNC_MIN; break;
+ case ScGeneralFunction::PRODUCT: mnAggFunc = EXC_SXDI_FUNC_PRODUCT; break;
+ case ScGeneralFunction::COUNTNUMS: mnAggFunc = EXC_SXDI_FUNC_COUNTNUM; break;
+ case ScGeneralFunction::STDEV: mnAggFunc = EXC_SXDI_FUNC_STDDEV; break;
+ case ScGeneralFunction::STDEVP: mnAggFunc = EXC_SXDI_FUNC_STDDEVP; break;
+ case ScGeneralFunction::VAR: mnAggFunc = EXC_SXDI_FUNC_VAR; break;
+ case ScGeneralFunction::VARP: mnAggFunc = EXC_SXDI_FUNC_VARP; break;
+ default: mnAggFunc = EXC_SXDI_FUNC_SUM;
}
}
diff --git a/sc/source/filter/inc/xlpivot.hxx b/sc/source/filter/inc/xlpivot.hxx
index 26a7d30188eb..62605f1525ef 100644
--- a/sc/source/filter/inc/xlpivot.hxx
+++ b/sc/source/filter/inc/xlpivot.hxx
@@ -36,6 +36,7 @@
class XclImpStream;
class XclExpStream;
+enum class ScGeneralFunction;
// Constants and Enumerations =================================================
@@ -580,7 +581,7 @@ XclExpStream& operator<<( XclExpStream& rStrm, const XclPTItemInfo& rInfo );
// General field settings =====================================================
-typedef ::std::vector< sal_uInt16 > XclPTSubtotalVec;
+typedef ::std::vector< ScGeneralFunction > XclPTSubtotalVec;
/** Contains data for a pivot table field (SXVD record). */
struct XclPTFieldInfo : public XclPTVisNameInfo
@@ -676,9 +677,9 @@ struct XclPTDataFieldInfo : public XclPTVisNameInfo
explicit XclPTDataFieldInfo();
/** Returns the API enum representing the aggregation function. */
- css::sheet::GeneralFunction GetApiAggFunc() const;
+ ScGeneralFunction GetApiAggFunc() const;
/** Sets the aggregation function represented by the passed API enum. */
- void SetApiAggFunc( css::sheet::GeneralFunction eAggFunc );
+ void SetApiAggFunc( ScGeneralFunction eAggFunc );
/** Returns the API constant representing the result reference type. */
sal_Int32 GetApiRefType() const;
diff --git a/sc/source/filter/xml/XMLConverter.cxx b/sc/source/filter/xml/XMLConverter.cxx
index 2437a6e49444..c2b41d09e4ea 100644
--- a/sc/source/filter/xml/XMLConverter.cxx
+++ b/sc/source/filter/xml/XMLConverter.cxx
@@ -29,6 +29,7 @@
#include "convuno.hxx"
#include "document.hxx"
#include "ftools.hxx"
+#include "generalfunction.hxx"
using namespace ::com::sun::star;
using namespace xmloff::token;
@@ -72,35 +73,35 @@ sheet::GeneralFunction ScXMLConverter::GetFunctionFromString( const OUString& sF
return sheet::GeneralFunction_NONE;
}
-sal_Int16 ScXMLConverter::GetFunctionFromString2( const OUString& sFunction )
+ScGeneralFunction ScXMLConverter::GetFunctionFromString2( const OUString& sFunction )
{
if( IsXMLToken(sFunction, XML_SUM ) )
- return sheet::GeneralFunction2::SUM;
+ return ScGeneralFunction::SUM;
if( IsXMLToken(sFunction, XML_AUTO ) )
- return sheet::GeneralFunction2::AUTO;
+ return ScGeneralFunction::AUTO;
if( IsXMLToken(sFunction, XML_COUNT ) )
- return sheet::GeneralFunction2::COUNT;
+ return ScGeneralFunction::COUNT;
if( IsXMLToken(sFunction, XML_COUNTNUMS ) )
- return sheet::GeneralFunction2::COUNTNUMS;
+ return ScGeneralFunction::COUNTNUMS;
if( IsXMLToken(sFunction, XML_PRODUCT ) )
- return sheet::GeneralFunction2::PRODUCT;
+ return ScGeneralFunction::PRODUCT;
if( IsXMLToken(sFunction, XML_AVERAGE ) )
- return sheet::GeneralFunction2::AVERAGE;
+ return ScGeneralFunction::AVERAGE;
if( IsXMLToken(sFunction, XML_MEDIAN ) )
- return sheet::GeneralFunction2::MEDIAN;
+ return ScGeneralFunction::MEDIAN;
if( IsXMLToken(sFunction, XML_MAX ) )
- return sheet::GeneralFunction2::MAX;
+ return ScGeneralFunction::MAX;
if( IsXMLToken(sFunction, XML_MIN ) )
- return sheet::GeneralFunction2::MIN;
+ return ScGeneralFunction::MIN;
if( IsXMLToken(sFunction, XML_STDEV ) )
- return sheet::GeneralFunction2::STDEV;
+ return ScGeneralFunction::STDEV;
if( IsXMLToken(sFunction, XML_STDEVP ) )
- return sheet::GeneralFunction2::STDEVP;
+ return ScGeneralFunction::STDEVP;
if( IsXMLToken(sFunction, XML_VAR ) )
- return sheet::GeneralFunction2::VAR;
+ return ScGeneralFunction::VAR;
if( IsXMLToken(sFunction, XML_VARP ) )
- return sheet::GeneralFunction2::VARP;
- return sheet::GeneralFunction2::NONE;
+ return ScGeneralFunction::VARP;
+ return ScGeneralFunction::NONE;
}
ScSubTotalFunc ScXMLConverter::GetSubTotalFuncFromString( const OUString& sFunction )
diff --git a/sc/source/filter/xml/XMLConverter.hxx b/sc/source/filter/xml/XMLConverter.hxx
index 41535c357136..c35d90de12f2 100644
--- a/sc/source/filter/xml/XMLConverter.hxx
+++ b/sc/source/filter/xml/XMLConverter.hxx
@@ -33,6 +33,7 @@
class ScDocument;
class DateTime;
+enum class ScGeneralFunction;
class ScXMLConverter
{
@@ -47,7 +48,8 @@ public:
static css::sheet::GeneralFunction
GetFunctionFromString(
const OUString& rString );
- static sal_Int16 GetFunctionFromString2(
+ static ScGeneralFunction
+ GetFunctionFromString2(
const OUString& rString );
static ScSubTotalFunc GetSubTotalFuncFromString(
diff --git a/sc/source/filter/xml/xmldpimp.cxx b/sc/source/filter/xml/xmldpimp.cxx
index be256ea7d21c..d7989a22e137 100644
--- a/sc/source/filter/xml/xmldpimp.cxx
+++ b/sc/source/filter/xml/xmldpimp.cxx
@@ -31,6 +31,7 @@
#include "dpdimsave.hxx"
#include "rangeutl.hxx"
#include "dpoutputgeometry.hxx"
+#include "generalfunction.hxx"
#include "pivotsource.hxx"
@@ -949,7 +950,7 @@ ScXMLDataPilotFieldContext::ScXMLDataPilotFieldContext( ScXMLImport& rImport,
fStep(0.0),
nUsedHierarchy(1),
nGroupPart(0),
- nFunction(0),
+ nFunction(ScGeneralFunction::NONE),
nOrientation(0),
bSelectedPage(false),
bIsGroupField(false),
@@ -1471,7 +1472,7 @@ void ScXMLDataPilotSubTotalsContext::EndElement()
pDataPilotField->SetSubTotalName(maDisplayName);
}
-void ScXMLDataPilotSubTotalsContext::AddFunction(sal_Int16 nFunction)
+void ScXMLDataPilotSubTotalsContext::AddFunction(ScGeneralFunction nFunction)
{
maFunctions.push_back(nFunction);
}
diff --git a/sc/source/filter/xml/xmldpimp.hxx b/sc/source/filter/xml/xmldpimp.hxx
index 09e29fc217a5..1519408f2bc9 100644
--- a/sc/source/filter/xml/xmldpimp.hxx
+++ b/sc/source/filter/xml/xmldpimp.hxx
@@ -292,7 +292,7 @@ class ScXMLDataPilotFieldContext : public ScXMLImportContext
double fStep;
sal_Int32 nUsedHierarchy;
sal_Int32 nGroupPart;
- sal_Int16 nFunction;
+ ScGeneralFunction nFunction;
sal_Int16 nOrientation;
bool bSelectedPage:1;
bool bIsGroupField:1;
@@ -318,7 +318,7 @@ public:
void SetShowEmpty(const bool bValue) { if (xDim) xDim->SetShowEmpty(bValue); }
void SetRepeatItemLabels(const bool bSet) { if (xDim) xDim->SetRepeatItemLabels(bSet); }
- void SetSubTotals(std::vector<sal_uInt16> const & rFunctions) { if (xDim) xDim->SetSubTotals(rFunctions); }
+ void SetSubTotals(std::vector<ScGeneralFunction> const & rFunctions) { if (xDim) xDim->SetSubTotals(rFunctions); }
void AddMember(ScDPSaveMember* pMember);
void SetSubTotalName(const OUString& rName);
void SetFieldReference(const css::sheet::DataPilotFieldReference& aRef) { if (xDim) xDim->SetReferenceValue(&aRef); }
@@ -411,10 +411,10 @@ public:
class ScXMLDataPilotSubTotalsContext : public ScXMLImportContext
{
- ScXMLDataPilotFieldContext* pDataPilotField;
+ ScXMLDataPilotFieldContext* pDataPilotField;
- std::vector<sal_uInt16> maFunctions;
- OUString maDisplayName;
+ std::vector<ScGeneralFunction> maFunctions;
+ OUString maDisplayName;
public:
ScXMLDataPilotSubTotalsContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
@@ -429,7 +429,7 @@ public:
const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override;
virtual void EndElement() override;
- void AddFunction(sal_Int16 nFunction);
+ void AddFunction(ScGeneralFunction nFunction);
void SetDisplayName(const OUString& rName);
};
diff --git a/sc/source/filter/xml/xmldrani.cxx b/sc/source/filter/xml/xmldrani.cxx
index 45b9b2965808..fa38154a7b8a 100644
--- a/sc/source/filter/xml/xmldrani.cxx
+++ b/sc/source/filter/xml/xmldrani.cxx
@@ -380,7 +380,7 @@ std::unique_ptr<ScDBData> ScXMLDatabaseRangeContext::ConvertToDBData(const OUStr
for (SCCOL i = 0; i < nCount; ++i)
{
aParam.pSubTotals[nPos][i] = static_cast<SCCOL>(pAry[i].Column);
- aParam.pFunctions[nPos][i] = ScDPUtil::toSubTotalFunc(pAry[i].Function);
+ aParam.pFunctions[nPos][i] = ScDPUtil::toSubTotalFunc((ScGeneralFunction)pAry[i].Function);
}
}
else
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index cf65be623bf9..c2ce3570f501 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -1829,7 +1829,7 @@ double SAL_CALL ScCellRangesBase::computeFunction( sheet::GeneralFunction nFunct
ScAddress aDummy; // if not marked, ignored if it is negative
double fVal;
- ScSubTotalFunc eFunc = ScDPUtil::toSubTotalFunc(nFunction);
+ ScSubTotalFunc eFunc = ScDPUtil::toSubTotalFunc((ScGeneralFunction)nFunction);
ScDocument& rDoc = pDocShell->GetDocument();
if ( !rDoc.GetSelectionFunction( eFunc, aDummy, aMark, fVal ) )
{
diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx
index 3ca0d809a848..778289382bdd 100644
--- a/sc/source/ui/unoobj/dapiuno.cxx
+++ b/sc/source/ui/unoobj/dapiuno.cxx
@@ -40,6 +40,7 @@
#include "hints.hxx"
#include <dputil.hxx>
#include "globstr.hrc"
+#include "generalfunction.hxx"
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
#include <com/sun/star/lang/IllegalArgumentException.hpp>
@@ -186,22 +187,22 @@ SC_SIMPLE_SERVICE_INFO( ScDataPilotFieldGroupItemObj, "ScDataPilotFieldGroupItem
// name that is used in the API for the data layout field
#define SC_DATALAYOUT_NAME "Data"
-sal_Int16 ScDataPilotConversion::FirstFunc( PivotFunc nBits )
+ScGeneralFunction ScDataPilotConversion::FirstFunc( PivotFunc nBits )
{
- if ( nBits & PivotFunc::Sum ) return GeneralFunction2::SUM;
- if ( nBits & PivotFunc::Count ) return GeneralFunction2::COUNT;
- if ( nBits & PivotFunc::Average ) return GeneralFunction2::AVERAGE;
- if ( nBits & PivotFunc::Median ) return GeneralFunction2::MEDIAN;
- if ( nBits & PivotFunc::Max ) return GeneralFunction2::MAX;
- if ( nBits & PivotFunc::Min ) return GeneralFunction2::MIN;
- if ( nBits & PivotFunc::Product ) return GeneralFunction2::PRODUCT;
- if ( nBits & PivotFunc::CountNum ) return GeneralFunction2::COUNTNUMS;
- if ( nBits & PivotFunc::StdDev ) return GeneralFunction2::STDEV;
- if ( nBits & PivotFunc::StdDevP ) return GeneralFunction2::STDEVP;
- if ( nBits & PivotFunc::StdVar ) return GeneralFunction2::VAR;
- if ( nBits & PivotFunc::StdVarP ) return GeneralFunction2::VARP;
- if ( nBits & PivotFunc::Auto ) return GeneralFunction2::AUTO;
- return GeneralFunction2::NONE;
+ if ( nBits & PivotFunc::Sum ) return ScGeneralFunction::SUM;
+ if ( nBits & PivotFunc::Count ) return ScGeneralFunction::COUNT;
+ if ( nBits & PivotFunc::Average ) return ScGeneralFunction::AVERAGE;
+ if ( nBits & PivotFunc::Median ) return ScGeneralFunction::MEDIAN;
+ if ( nBits & PivotFunc::Max ) return ScGeneralFunction::MAX;
+ if ( nBits & PivotFunc::Min ) return ScGeneralFunction::MIN;
+ if ( nBits & PivotFunc::Product ) return ScGeneralFunction::PRODUCT;
+ if ( nBits & PivotFunc::CountNum ) return ScGeneralFunction::COUNTNUMS;
+ if ( nBits & PivotFunc::StdDev ) return ScGeneralFunction::STDEV;
+ if ( nBits & PivotFunc::StdDevP ) return ScGeneralFunction::STDEVP;
+ if ( nBits & PivotFunc::StdVar ) return ScGeneralFunction::VAR;
+ if ( nBits & PivotFunc::StdVarP ) return ScGeneralFunction::VARP;
+ if ( nBits & PivotFunc::Auto ) return ScGeneralFunction::AUTO;
+ return ScGeneralFunction::NONE;
}
PivotFunc ScDataPilotConversion::FunctionBit( sal_Int16 eFunc )
@@ -1814,34 +1815,40 @@ void SAL_CALL ScDataPilotFieldObj::setPropertyValue( const OUString& aPropertyNa
if ( aPropertyName == SC_UNONAME_FUNCTION )
{
// #i109350# use GetEnumFromAny because it also allows sal_Int32
- GeneralFunction eFunction = (GeneralFunction)
+ ScGeneralFunction eFunction = (ScGeneralFunction)
ScUnoHelpFunctions::GetEnumFromAny( aValue );
- setFunction( static_cast<sal_Int16> (eFunction) );
+ setFunction( eFunction );
}
else if ( aPropertyName == SC_UNONAME_FUNCTION2 )
{
- sal_Int16 eFunction = ScUnoHelpFunctions::GetInt16FromAny( aValue );
+ ScGeneralFunction eFunction = (ScGeneralFunction)ScUnoHelpFunctions::GetInt16FromAny( aValue );
setFunction( eFunction );
}
else if ( aPropertyName == SC_UNONAME_SUBTOTALS )
{
- Sequence< sal_Int16 > aSubTotals;
uno::Sequence<sheet::GeneralFunction> aSeq;
if( aValue >>= aSeq)
{
- aSubTotals.realloc(aSeq.getLength());
+ std::vector< ScGeneralFunction > aSubTotals(aSeq.getLength());
for (sal_Int32 nIndex = 0; nIndex < aSeq.getLength(); nIndex++)
{
- aSubTotals[nIndex] = static_cast<sal_Int16>(aSeq[nIndex]);
+ aSubTotals[nIndex] = static_cast<ScGeneralFunction>(aSeq[nIndex]);
}
setSubtotals( aSubTotals );
}
}
else if ( aPropertyName == SC_UNONAME_SUBTOTALS2 )
{
- Sequence< sal_Int16 > aSubtotals;
- if( aValue >>= aSubtotals )
- setSubtotals( aSubtotals );
+ Sequence< sal_Int16 > aSeq;
+ if( aValue >>= aSeq )
+ {
+ std::vector< ScGeneralFunction > aSubTotals(aSeq.getLength());
+ for (sal_Int32 nIndex = 0; nIndex < aSeq.getLength(); nIndex++)
+ {
+ aSubTotals[nIndex] = static_cast<ScGeneralFunction>(aSeq[nIndex]);
+ }
+ setSubtotals( aSubTotals );
+ }
}
else if ( aPropertyName == SC_UNONAME_ORIENT )
{
@@ -2112,7 +2119,7 @@ sal_Int16 ScDataPilotFieldObj::getFunction() const
return eRet;
}
-void ScDataPilotFieldObj::setFunction(sal_Int16 eNewFunc)
+void ScDataPilotFieldObj::setFunction(ScGeneralFunction eNewFunc)
{
SolarMutexGuard aGuard;
ScDPObject* pDPObj = nullptr;
@@ -2121,15 +2128,15 @@ void ScDataPilotFieldObj::setFunction(sal_Int16 eNewFunc)
if( pDim->GetOrientation() != DataPilotFieldOrientation_DATA )
{
// for non-data fields, property Function is the subtotals
- std::vector<sal_uInt16> nSubTotalFuncs;
- if ( eNewFunc != GeneralFunction2::NONE )
+ std::vector<ScGeneralFunction> nSubTotalFuncs;
+ if ( eNewFunc != ScGeneralFunction::NONE )
{
- nSubTotalFuncs.push_back( sal::static_int_cast<sal_uInt16>( eNewFunc ) );
+ nSubTotalFuncs.push_back( eNewFunc );
}
pDim->SetSubTotals( nSubTotalFuncs );
}
else
- pDim->SetFunction( sal::static_int_cast<sal_uInt16>( eNewFunc ) );
+ pDim->SetFunction( eNewFunc );
SetDPObject( pDPObj );
}
}
@@ -2155,7 +2162,7 @@ Sequence< sal_Int16 > ScDataPilotFieldObj::getSubtotals() const
return aRet;
}
-void ScDataPilotFieldObj::setSubtotals( const Sequence< sal_Int16 >& rSubtotals )
+void ScDataPilotFieldObj::setSubtotals( const std::vector< ScGeneralFunction >& rSubtotals )
{
SolarMutexGuard aGuard;
ScDPObject* pDPObj = nullptr;
@@ -2163,30 +2170,29 @@ void ScDataPilotFieldObj::setSubtotals( const Sequence< sal_Int16 >& rSubtotals
{
if( pDim->GetOrientation() != DataPilotFieldOrientation_DATA )
{
- sal_Int32 nCount = rSubtotals.getLength();
+ sal_Int32 nCount = rSubtotals.size();
if( nCount == 1 )
{
// count 1: all values are allowed (including NONE and AUTO)
- std::vector<sal_uInt16> nTmpFuncs;
- if( rSubtotals[ 0 ] != GeneralFunction2::NONE )
+ std::vector<ScGeneralFunction> nTmpFuncs;
+ if( rSubtotals[ 0 ] != ScGeneralFunction::NONE )
{
- nTmpFuncs.push_back( sal::static_int_cast<sal_uInt16>( rSubtotals[ 0 ] ) );
+ nTmpFuncs.push_back( rSubtotals[ 0 ] );
}
pDim->SetSubTotals( nTmpFuncs );
}
else if( nCount > 1 )
{
// set multiple functions, ignore NONE and AUTO in this case
- ::std::vector< sal_uInt16 > aSubt;
+ ::std::vector< ScGeneralFunction > aSubt;
for( sal_Int32 nIdx = 0; nIdx < nCount; ++nIdx )
{
- sal_Int16 eFunc = rSubtotals[ nIdx ];
- if( (eFunc != GeneralFunction2::NONE) && (eFunc != GeneralFunction2::AUTO) )
+ ScGeneralFunction eFunc = rSubtotals[ nIdx ];
+ if( (eFunc != ScGeneralFunction::NONE) && (eFunc != ScGeneralFunction::AUTO) )
{
// do not insert functions twice
- sal_uInt16 nFunc = static_cast< sal_uInt16 >( eFunc );
- if( ::std::find( aSubt.begin(), aSubt.end(), nFunc ) == aSubt.end() )
- aSubt.push_back( nFunc );
+ if( ::std::find( aSubt.begin(), aSubt.end(), eFunc ) == aSubt.end() )
+ aSubt.push_back( eFunc );
}
}
// set values from vector to ScDPSaveDimension
diff --git a/sc/source/ui/unoobj/datauno.cxx b/sc/source/ui/unoobj/datauno.cxx
index 449741feb5d6..9abb7521f5e3 100644
--- a/sc/source/ui/unoobj/datauno.cxx
+++ b/sc/source/ui/unoobj/datauno.cxx
@@ -518,7 +518,7 @@ void SAL_CALL ScSubTotalFieldObj::setSubTotalColumns(
for (SCCOL i=0; i<nCount; i++)
{
aParam.pSubTotals[nPos][i] = static_cast<SCCOL>(pAry[i].Column);
- aParam.pFunctions[nPos][i] = ScDPUtil::toSubTotalFunc(pAry[i].Function);
+ aParam.pFunctions[nPos][i] = ScDPUtil::toSubTotalFunc((ScGeneralFunction)pAry[i].Function);
}
}
else
@@ -597,7 +597,7 @@ void SAL_CALL ScSubTotalDescriptorBase::addNew(
for (SCCOL i=0; i<nCount; i++)
{
aParam.pSubTotals[nPos][i] = static_cast<SCCOL>(pAry[i].Column);
- aParam.pFunctions[nPos][i] = ScDPUtil::toSubTotalFunc(pAry[i].Function);
+ aParam.pFunctions[nPos][i] = ScDPUtil::toSubTotalFunc((ScGeneralFunction)pAry[i].Function);
}
}
else
@@ -840,7 +840,7 @@ sheet::GeneralFunction SAL_CALL ScConsolidationDescriptor::getFunction()
void SAL_CALL ScConsolidationDescriptor::setFunction( sheet::GeneralFunction nFunction )
{
SolarMutexGuard aGuard;
- aParam.eFunction = ScDPUtil::toSubTotalFunc(nFunction);
+ aParam.eFunction = ScDPUtil::toSubTotalFunc((ScGeneralFunction)nFunction);
}
uno::Sequence<table::CellRangeAddress> SAL_CALL ScConsolidationDescriptor::getSources()
diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx
index a0a20ae9b3ef..ad0f714e9b65 100644
--- a/sc/source/ui/view/dbfunc3.cxx
+++ b/sc/source/ui/view/dbfunc3.cxx
@@ -67,6 +67,7 @@
#include "markdata.hxx"
#include "stringutil.hxx"
#include "tabvwsh.hxx"
+#include "generalfunction.hxx"
#include <list>
#include <memory>
@@ -1525,7 +1526,7 @@ void ScDBFunc::DataPilotInput( const ScAddress& rPos, const OUString& rString )
if (pDim->GetSubTotalsCount() != 1)
break;
- if (pDim->GetSubTotalFunc(0) != sheet::GeneralFunction_AUTO)
+ if (pDim->GetSubTotalFunc(0) != ScGeneralFunction::AUTO)
break;
const OUString* pLayoutName = pMem->GetLayoutName();