diff options
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/core/data/dpobject.cxx | 64 | ||||
-rw-r--r-- | sc/source/core/data/dpoutput.cxx | 40 | ||||
-rw-r--r-- | sc/source/core/data/dpsave.cxx | 15 | ||||
-rw-r--r-- | sc/source/core/data/dptabres.cxx | 13 | ||||
-rw-r--r-- | sc/source/core/data/dptabsrc.cxx | 66 | ||||
-rw-r--r-- | sc/source/core/data/dputil.cxx | 30 | ||||
-rw-r--r-- | sc/source/core/tool/interpr2.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/xml/XMLConverter.cxx | 70 | ||||
-rw-r--r-- | sc/source/filter/xml/XMLConverter.hxx | 7 | ||||
-rw-r--r-- | sc/source/filter/xml/XMLExportDataPilot.cxx | 10 | ||||
-rw-r--r-- | sc/source/filter/xml/xmldpimp.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/unoobj/dapiuno.cxx | 150 | ||||
-rw-r--r-- | sc/source/ui/unoobj/datauno.cxx | 6 |
13 files changed, 306 insertions, 172 deletions
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx index 22d8744e0d23..3e1813c69968 100644 --- a/sc/source/core/data/dpobject.cxx +++ b/sc/source/core/data/dpobject.cxx @@ -49,7 +49,7 @@ #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> #include <com/sun/star/sdbc/XRow.hpp> #include <com/sun/star/sdbc/XRowSet.hpp> -#include <com/sun/star/sheet/GeneralFunction.hpp> +#include <com/sun/star/sheet/GeneralFunction2.hpp> #include <com/sun/star/sheet/DataPilotFieldFilter.hpp> #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp> #include <com/sun/star/sheet/DataPilotFieldReferenceType.hpp> @@ -1335,7 +1335,7 @@ public: if (pLayoutName && ScGlobal::pCharClass->uppercase(*pLayoutName) == maName) return true; - sheet::GeneralFunction eGenFunc = static_cast<sheet::GeneralFunction>(pDim->GetFunction()); + sal_Int16 eGenFunc = pDim->GetFunction(); ScSubTotalFunc eFunc = ScDPUtil::toSubTotalFunc(eGenFunc); OUString aSrcName = ScDPUtil::getSourceDimensionName(pDim->GetName()); OUString aFuncName = ScDPUtil::getDisplayedMeasureName(aSrcName, eFunc); @@ -1491,29 +1491,29 @@ bool dequote( const OUString& rSource, sal_Int32 nStartPos, sal_Int32& rEndPos, struct ScGetPivotDataFunctionEntry { const sal_Char* pName; - sheet::GeneralFunction eFunc; + sal_Int16 eFunc; }; -bool parseFunction( const OUString& rList, sal_Int32 nStartPos, sal_Int32& rEndPos, sheet::GeneralFunction& rFunc ) +bool parseFunction( const OUString& rList, sal_Int32 nStartPos, sal_Int32& rEndPos, sal_Int16& rFunc ) { static const ScGetPivotDataFunctionEntry aFunctions[] = { // our names - { "Sum", sheet::GeneralFunction_SUM }, - { "Count", sheet::GeneralFunction_COUNT }, - { "Average", sheet::GeneralFunction_AVERAGE }, - { "Max", sheet::GeneralFunction_MAX }, - { "Min", sheet::GeneralFunction_MIN }, - { "Product", sheet::GeneralFunction_PRODUCT }, - { "CountNums", sheet::GeneralFunction_COUNTNUMS }, - { "StDev", sheet::GeneralFunction_STDEV }, - { "StDevp", sheet::GeneralFunction_STDEVP }, - { "Var", sheet::GeneralFunction_VAR }, - { "VarP", sheet::GeneralFunction_VARP }, + { "Sum", sheet::GeneralFunction2::SUM }, + { "Count", sheet::GeneralFunction2::COUNT }, + { "Average", sheet::GeneralFunction2::AVERAGE }, + { "Max", sheet::GeneralFunction2::MAX }, + { "Min", sheet::GeneralFunction2::MIN }, + { "Product", sheet::GeneralFunction2::PRODUCT }, + { "CountNums", sheet::GeneralFunction2::COUNTNUMS }, + { "StDev", sheet::GeneralFunction2::STDEV }, + { "StDevp", sheet::GeneralFunction2::STDEVP }, + { "Var", sheet::GeneralFunction2::VAR }, + { "VarP", sheet::GeneralFunction2::VARP }, // compatibility names - { "Count Nums", sheet::GeneralFunction_COUNTNUMS }, - { "StdDev", sheet::GeneralFunction_STDEV }, - { "StdDevp", sheet::GeneralFunction_STDEVP } + { "Count Nums", sheet::GeneralFunction2::COUNTNUMS }, + { "StdDev", sheet::GeneralFunction2::STDEV }, + { "StdDevp", sheet::GeneralFunction2::STDEVP } }; const sal_Int32 nListLen = rList.getLength(); @@ -1558,7 +1558,7 @@ bool parseFunction( const OUString& rList, sal_Int32 nStartPos, sal_Int32& rEndP return bFound; } -bool extractAtStart( const OUString& rList, sal_Int32& rMatched, bool bAllowBracket, sheet::GeneralFunction* pFunc, +bool extractAtStart( const OUString& rList, sal_Int32& rMatched, bool bAllowBracket, sal_Int16* pFunc, OUString& rDequoted ) { sal_Int32 nMatchList = 0; @@ -1663,7 +1663,7 @@ bool extractAtStart( const OUString& rList, sal_Int32& rMatched, bool bAllowBrac bool isAtStart( const OUString& rList, const OUString& rSearch, sal_Int32& rMatched, - bool bAllowBracket, sheet::GeneralFunction* pFunc ) + bool bAllowBracket, sal_Int16* pFunc ) { sal_Int32 nMatchList = 0; sal_Int32 nMatchSearch = 0; @@ -1714,7 +1714,7 @@ bool isAtStart( bool ScDPObject::ParseFilters( OUString& rDataFieldName, std::vector<sheet::DataPilotFieldFilter>& rFilters, - std::vector<sheet::GeneralFunction>& rFilterFuncs, const OUString& rFilterList ) + std::vector<sal_Int16>& rFilterFuncs, const OUString& rFilterList ) { // parse the string rFilterList into parameters for GetPivotData @@ -1868,8 +1868,8 @@ bool ScDPObject::ParseFilters( OUString aFoundName; OUString aFoundValueName; OUString aFoundValue; - sheet::GeneralFunction eFunc = sheet::GeneralFunction_NONE; - sheet::GeneralFunction eFoundFunc = sheet::GeneralFunction_NONE; + sal_Int16 eFunc = sheet::GeneralFunction2::NONE; + sal_Int16 eFoundFunc = sheet::GeneralFunction2::NONE; OUString aQueryValueName; const bool bHasQuery = extractAtStart( aRemaining, nMatched, false, &eFunc, aQueryValueName); @@ -2118,16 +2118,16 @@ static PivotFunc lcl_FirstSubTotal( const uno::Reference<beans::XPropertySet>& x uno::Any aSubAny; try { - aSubAny = xLevProp->getPropertyValue( SC_UNO_DP_SUBTOTAL ); + aSubAny = xLevProp->getPropertyValue( SC_UNO_DP_SUBTOTAL2 ); } catch(uno::Exception&) { } - uno::Sequence<sheet::GeneralFunction> aSeq; + uno::Sequence<sal_Int16> aSeq; if ( aSubAny >>= aSeq ) { PivotFunc nMask = PivotFunc::NONE; - const sheet::GeneralFunction* pArray = aSeq.getConstArray(); + const sal_Int16* pArray = aSeq.getConstArray(); long nCount = aSeq.getLength(); for (long i=0; i<nCount; i++) nMask |= ScDataPilotConversion::FunctionBit(pArray[i]); @@ -2195,13 +2195,13 @@ void lcl_FillOldFields( ScPivotFieldVector& rFields, PivotFunc nMask = PivotFunc::NONE; if ( nOrient == sheet::DataPilotFieldOrientation_DATA ) { - sheet::GeneralFunction eFunc = (sheet::GeneralFunction)ScUnoHelpFunctions::GetEnumProperty( - xDimProp, SC_UNO_DP_FUNCTION, - sheet::GeneralFunction_NONE ); - if ( eFunc == sheet::GeneralFunction_AUTO ) + sal_Int16 eFunc = (sal_Int16)ScUnoHelpFunctions::GetEnumProperty( + xDimProp, SC_UNO_DP_FUNCTION2, + sheet::GeneralFunction2::NONE ); + if ( eFunc == sheet::GeneralFunction2::AUTO ) { //TODO: test for numeric data - eFunc = sheet::GeneralFunction_SUM; + eFunc = sheet::GeneralFunction2::SUM; } nMask = ScDataPilotConversion::FunctionBit(eFunc); } @@ -2683,7 +2683,7 @@ void ScDPObject::ConvertOrientation( bFirst = std::none_of(itrBeg, itr, FindByOriginalDim(nCol)); } - sheet::GeneralFunction eFunc = ScDataPilotConversion::FirstFunc(rField.nFuncMask); + sal_Int16 eFunc = ScDataPilotConversion::FirstFunc(rField.nFuncMask); if (!bFirst) pDim = rSaveData.DuplicateDimension(pDim->GetName()); pDim->SetOrientation(nOrient); diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx index 1bd6a62a5379..1fd2c3f81bd9 100644 --- a/sc/source/core/data/dpoutput.cxx +++ b/sc/source/core/data/dpoutput.cxx @@ -52,6 +52,7 @@ #include <com/sun/star/sheet/MemberResultFlags.hpp> #include <com/sun/star/sheet/DataResultFlags.hpp> #include <com/sun/star/sheet/DataPilotTablePositionType.hpp> +#include <com/sun/star/sheet/GeneralFunction2.hpp> #include <vector> @@ -1538,28 +1539,25 @@ bool ScDPOutput::GetDataResultPositionData(vector<sheet::DataPilotFieldFilter>& namespace { -OUString lcl_GetDataFieldName( const OUString& rSourceName, sheet::GeneralFunction eFunc ) +OUString lcl_GetDataFieldName( const OUString& rSourceName, sal_Int16 eFunc ) { sal_uInt16 nStrId = 0; switch ( eFunc ) { - case sheet::GeneralFunction_SUM: nStrId = STR_FUN_TEXT_SUM; break; - case sheet::GeneralFunction_COUNT: - case sheet::GeneralFunction_COUNTNUMS: nStrId = STR_FUN_TEXT_COUNT; break; - case sheet::GeneralFunction_AVERAGE: nStrId = STR_FUN_TEXT_AVG; break; -#if 0 -// disabled because of css::sheet::GeneralFunction API incompatibility - case sheet::GeneralFunction_MEDIAN: nStrId = STR_FUN_TEXT_MEDIAN; break; -#endif - case sheet::GeneralFunction_MAX: nStrId = STR_FUN_TEXT_MAX; break; - case sheet::GeneralFunction_MIN: nStrId = STR_FUN_TEXT_MIN; break; - case sheet::GeneralFunction_PRODUCT: nStrId = STR_FUN_TEXT_PRODUCT; break; - case sheet::GeneralFunction_STDEV: - case sheet::GeneralFunction_STDEVP: nStrId = STR_FUN_TEXT_STDDEV; break; - case sheet::GeneralFunction_VAR: - case sheet::GeneralFunction_VARP: nStrId = STR_FUN_TEXT_VAR; break; - case sheet::GeneralFunction_NONE: - case sheet::GeneralFunction_AUTO: break; + case sheet::GeneralFunction2::SUM: nStrId = STR_FUN_TEXT_SUM; break; + case sheet::GeneralFunction2::COUNT: + case sheet::GeneralFunction2::COUNTNUMS: nStrId = STR_FUN_TEXT_COUNT; break; + case sheet::GeneralFunction2::AVERAGE: nStrId = STR_FUN_TEXT_AVG; break; + case sheet::GeneralFunction2::MEDIAN: nStrId = STR_FUN_TEXT_MEDIAN; break; + case sheet::GeneralFunction2::MAX: nStrId = STR_FUN_TEXT_MAX; break; + case sheet::GeneralFunction2::MIN: nStrId = STR_FUN_TEXT_MIN; break; + case sheet::GeneralFunction2::PRODUCT: nStrId = STR_FUN_TEXT_PRODUCT; break; + case sheet::GeneralFunction2::STDEV: + case sheet::GeneralFunction2::STDEVP: nStrId = STR_FUN_TEXT_STDDEV; break; + case sheet::GeneralFunction2::VAR: + case sheet::GeneralFunction2::VARP: nStrId = STR_FUN_TEXT_VAR; break; + case sheet::GeneralFunction2::NONE: + case sheet::GeneralFunction2::AUTO: break; default: { assert(false); @@ -1590,9 +1588,9 @@ void ScDPOutput::GetDataDimensionNames( // Generate "given name" the same way as in dptabres. //TODO: Should use a stored name when available - sheet::GeneralFunction eFunc = (sheet::GeneralFunction)ScUnoHelpFunctions::GetEnumProperty( - xDimProp, SC_UNO_DP_FUNCTION, - sheet::GeneralFunction_NONE ); + sal_Int16 eFunc = (sal_Int16)ScUnoHelpFunctions::GetEnumProperty( + xDimProp, SC_UNO_DP_FUNCTION2, + sheet::GeneralFunction2::NONE ); rGivenName = lcl_GetDataFieldName( rSourceName, eFunc ); } } diff --git a/sc/source/core/data/dpsave.cxx b/sc/source/core/data/dpsave.cxx index a3fae76e23d7..54f98850c2de 100644 --- a/sc/source/core/data/dpsave.cxx +++ b/sc/source/core/data/dpsave.cxx @@ -33,6 +33,7 @@ #include <comphelper/stl_types.hxx> #include <com/sun/star/sheet/GeneralFunction.hpp> +#include <com/sun/star/sheet/GeneralFunction2.hpp> #include <com/sun/star/sheet/DataPilotFieldAutoShowInfo.hpp> #include <com/sun/star/sheet/DataPilotFieldLayoutInfo.hpp> #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp> @@ -194,7 +195,7 @@ ScDPSaveDimension::ScDPSaveDimension(const OUString& rName, bool bDataLayout) : bIsDataLayout( bDataLayout ), bDupFlag( false ), nOrientation( sheet::DataPilotFieldOrientation_HIDDEN ), - nFunction( sheet::GeneralFunction_AUTO ), + nFunction( sheet::GeneralFunction2::AUTO ), nUsedHierarchy( -1 ), nShowEmptyMode( SC_DPSAVEMODE_DONTKNOW ), bRepeatItemLabels( false ), @@ -563,8 +564,8 @@ void ScDPSaveDimension::WriteToSource( const uno::Reference<uno::XInterface>& xD sheet::DataPilotFieldOrientation eOrient = (sheet::DataPilotFieldOrientation)nOrientation; xDimProp->setPropertyValue( SC_UNO_DP_ORIENTATION, uno::Any(eOrient) ); - sheet::GeneralFunction eFunc = (sheet::GeneralFunction)nFunction; - xDimProp->setPropertyValue( SC_UNO_DP_FUNCTION, uno::Any(eFunc) ); + sal_Int16 eFunc = static_cast<sal_Int16>(nFunction); + xDimProp->setPropertyValue( SC_UNO_DP_FUNCTION2, uno::Any(eFunc) ); if ( nUsedHierarchy >= 0 ) { @@ -629,11 +630,11 @@ void ScDPSaveDimension::WriteToSource( const uno::Reference<uno::XInterface>& xD if ( !pSubTotalFuncs ) nSubTotalCount = 0; - uno::Sequence<sheet::GeneralFunction> aSeq(nSubTotalCount); - sheet::GeneralFunction* pArray = aSeq.getArray(); + uno::Sequence<sal_Int16> aSeq(nSubTotalCount); + sal_Int16* pArray = aSeq.getArray(); for (long i=0; i<nSubTotalCount; i++) - pArray[i] = (sheet::GeneralFunction)pSubTotalFuncs[i]; - xLevProp->setPropertyValue( SC_UNO_DP_SUBTOTAL, uno::Any(aSeq) ); + pArray[i] = static_cast<sal_Int16>(pSubTotalFuncs[i]); + xLevProp->setPropertyValue( SC_UNO_DP_SUBTOTAL2, uno::Any(aSeq) ); } if ( nShowEmptyMode != SC_DPSAVEMODE_DONTKNOW ) lcl_SetBoolProperty( xLevProp, diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx index 6747347a1c67..c20c2a94160d 100644 --- a/sc/source/core/data/dptabres.cxx +++ b/sc/source/core/data/dptabres.cxx @@ -48,6 +48,7 @@ #include <com/sun/star/sheet/DataPilotFieldReferenceItemType.hpp> #include <com/sun/star/sheet/DataPilotFieldShowItemsMode.hpp> #include <com/sun/star/sheet/DataPilotFieldSortMode.hpp> +#include <com/sun/star/sheet/GeneralFunction2.hpp> using namespace com::sun::star; using ::std::vector; @@ -729,9 +730,9 @@ static ScSubTotalFunc lcl_GetForceFunc( const ScDPLevel* pLevel, long nFuncNo ) { //TODO: direct access via ScDPLevel - uno::Sequence<sheet::GeneralFunction> aSeq = pLevel->getSubTotals(); + uno::Sequence<sal_Int16> aSeq = pLevel->getSubTotals(); long nSequence = aSeq.getLength(); - if ( nSequence && aSeq[0] != sheet::GeneralFunction_AUTO ) + if ( nSequence && aSeq[0] != sheet::GeneralFunction2::AUTO ) { // For manual subtotals, "automatic" is added as first function. // ScDPResultMember::GetSubTotalCount adds to the count, here NONE has to be @@ -742,8 +743,8 @@ static ScSubTotalFunc lcl_GetForceFunc( const ScDPLevel* pLevel, long nFuncNo ) if ( nFuncNo >= 0 && nFuncNo < nSequence ) { - sheet::GeneralFunction eUser = aSeq.getConstArray()[nFuncNo]; - if (eUser != sheet::GeneralFunction_AUTO) + sal_Int16 eUser = aSeq.getConstArray()[nFuncNo]; + if (eUser != sheet::GeneralFunction2::AUTO) eRet = ScDPUtil::toSubTotalFunc(eUser); } } @@ -1237,9 +1238,9 @@ long ScDPResultMember::GetSubTotalCount( long* pUserSubStart ) const { //TODO: direct access via ScDPLevel - uno::Sequence<sheet::GeneralFunction> aSeq = pParentLevel->getSubTotals(); + uno::Sequence<sal_Int16> aSeq = pParentLevel->getSubTotals(); long nSequence = aSeq.getLength(); - if ( nSequence && aSeq[0] != sheet::GeneralFunction_AUTO ) + if ( nSequence && aSeq[0] != sheet::GeneralFunction2::AUTO ) { // For manual subtotals, always add "automatic" as first function // (used for calculation, but not for display, needed for sorting, see lcl_GetForceFunc) diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx index cc024ac56cfa..8285aa11b187 100644 --- a/sc/source/core/data/dptabsrc.cxx +++ b/sc/source/core/data/dptabsrc.cxx @@ -54,6 +54,7 @@ #include <com/sun/star/sheet/DataPilotFieldSortMode.hpp> #include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp> #include <com/sun/star/sheet/DataPilotFieldAutoShowInfo.hpp> +#include <com/sun/star/sheet/GeneralFunction2.hpp> #include <comphelper/string.hxx> #include <unotools/collatorwrapper.hxx> @@ -798,11 +799,11 @@ void ScDPSource::CreateRes_Impl() // Get function for each data field. long nDimIndex = *it; ScDPDimension* pDim = GetDimensionsObject()->getByIndex(nDimIndex); - sheet::GeneralFunction eUser = (sheet::GeneralFunction)pDim->getFunction(); - if (eUser == sheet::GeneralFunction_AUTO) + sal_Int16 eUser = static_cast<sal_Int16>(pDim->getFunction()); + if (eUser == sheet::GeneralFunction2::AUTO) { //TODO: test for numeric data - eUser = sheet::GeneralFunction_SUM; + eUser = sheet::GeneralFunction2::SUM; } // Map UNO's enum to internal enum ScSubTotalFunc. @@ -1465,6 +1466,7 @@ uno::Reference<beans::XPropertySetInfo> SAL_CALL ScDPDimension::getPropertySetIn { OUString(SC_UNO_DP_FILTER), 0, cppu::UnoType<uno::Sequence<sheet::TableFilterField>>::get(), 0, 0 }, { OUString(SC_UNO_DP_FLAGS), 0, cppu::UnoType<sal_Int32>::get(), beans::PropertyAttribute::READONLY, 0 }, { OUString(SC_UNO_DP_FUNCTION), 0, cppu::UnoType<sheet::GeneralFunction>::get(), 0, 0 }, + { OUString(SC_UNO_DP_FUNCTION2), 0, cppu::UnoType<sal_Int16>::get(), 0, 0 }, { OUString(SC_UNO_DP_ISDATALAYOUT), 0, cppu::UnoType<bool>::get(), beans::PropertyAttribute::READONLY, 0 }, { OUString(SC_UNO_DP_NUMBERFO), 0, cppu::UnoType<sal_Int32>::get(), beans::PropertyAttribute::READONLY, 0 }, { OUString(SC_UNO_DP_ORIENTATION), 0, cppu::UnoType<sheet::DataPilotFieldOrientation>::get(), 0, 0 }, @@ -1504,6 +1506,12 @@ void SAL_CALL ScDPDimension::setPropertyValue( const OUString& aPropertyName, co if (aValue >>= eEnum) setFunction( sal::static_int_cast<sal_uInt16>(eEnum) ); } + else if ( aPropertyName == SC_UNO_DP_FUNCTION2 ) + { + sal_Int16 eEnum; + if (aValue >>= eEnum) + setFunction( eEnum ); + } else if ( aPropertyName == SC_UNO_DP_REFVALUE ) aValue >>= aReferenceValue; else if ( aPropertyName == SC_UNO_DP_FILTER ) @@ -1578,7 +1586,21 @@ uno::Any SAL_CALL ScDPDimension::getPropertyValue( const OUString& aPropertyName } else if ( aPropertyName == SC_UNO_DP_FUNCTION ) { - sheet::GeneralFunction eVal = (sheet::GeneralFunction)getFunction(); + 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; + } + else if ( aPropertyName == SC_UNO_DP_FUNCTION2 ) + { + sal_Int16 eVal = getFunction(); aRet <<= eVal; } else if ( aPropertyName == SC_UNO_DP_REFVALUE ) @@ -1588,9 +1610,9 @@ uno::Any SAL_CALL ScDPDimension::getPropertyValue( const OUString& aPropertyName else if ( aPropertyName == SC_UNO_DP_NUMBERFO ) { sal_Int32 nFormat = 0; - sheet::GeneralFunction eFunc = (sheet::GeneralFunction)getFunction(); + sal_Int16 eFunc = getFunction(); // #i63745# don't use source format for "count" - if ( eFunc != sheet::GeneralFunction_COUNT && eFunc != sheet::GeneralFunction_COUNTNUMS ) + if ( eFunc != sheet::GeneralFunction2::COUNT && eFunc != sheet::GeneralFunction2::COUNTNUMS ) nFormat = pSource->GetData()->GetNumberFormat( ( nSourceDim >= 0 ) ? nSourceDim : nDim ); switch ( aReferenceValue.ReferenceType ) @@ -2125,13 +2147,13 @@ void SAL_CALL ScDPLevel::setName( const OUString& /* rNewName */ ) throw(uno::Ru OSL_FAIL("not implemented"); //TODO: exception? } -uno::Sequence<sheet::GeneralFunction> ScDPLevel::getSubTotals() const +uno::Sequence<sal_Int16> ScDPLevel::getSubTotals() const { //TODO: separate functions for settings and evaluation? long nSrcDim = pSource->GetSourceDim( nDim ); if ( !pSource->SubTotalAllowed( nSrcDim ) ) - return uno::Sequence<sheet::GeneralFunction>(0); + return uno::Sequence<sal_Int16>(0); return aSubTotals; } @@ -2152,6 +2174,7 @@ uno::Reference<beans::XPropertySetInfo> SAL_CALL ScDPLevel::getPropertySetInfo() { OUString(SC_UNO_DP_REPEATITEMLABELS), 0, cppu::UnoType<bool>::get(), 0, 0 }, { OUString(SC_UNO_DP_SORTING), 0, cppu::UnoType<sheet::DataPilotFieldSortInfo>::get(), 0, 0 }, { OUString(SC_UNO_DP_SUBTOTAL), 0, cppu::UnoType<uno::Sequence<sheet::GeneralFunction>>::get(), 0, 0 }, + { OUString(SC_UNO_DP_SUBTOTAL2), 0, cppu::UnoType<uno::Sequence<sal_Int16>>::get(), 0, 0 }, { OUString(), 0, css::uno::Type(), 0, 0 } }; static uno::Reference<beans::XPropertySetInfo> aRef = @@ -2169,6 +2192,16 @@ void SAL_CALL ScDPLevel::setPropertyValue( const OUString& aPropertyName, const else if ( aPropertyName == SC_UNO_DP_REPEATITEMLABELS ) bRepeatItemLabels = lcl_GetBoolFromAny(aValue); else if ( aPropertyName == SC_UNO_DP_SUBTOTAL ) + { + uno::Sequence<sheet::GeneralFunction> aSeq; + aValue >>= aSeq; + aSubTotals.realloc(aSeq.getLength()); + for (sal_Int32 nIndex = 0; nIndex < aSeq.getLength(); nIndex++) + { + aSubTotals[nIndex] = static_cast<sal_Int16>(aSeq[nIndex]); + } + } + else if ( aPropertyName == SC_UNO_DP_SUBTOTAL2 ) aValue >>= aSubTotals; else if ( aPropertyName == SC_UNO_DP_SORTING ) aValue >>= aSortInfo; @@ -2193,7 +2226,22 @@ uno::Any SAL_CALL ScDPLevel::getPropertyValue( const OUString& aPropertyName ) aRet <<= bRepeatItemLabels; else if ( aPropertyName == SC_UNO_DP_SUBTOTAL ) { - uno::Sequence<sheet::GeneralFunction> aSeq = getSubTotals(); //TODO: avoid extra copy? + uno::Sequence<sal_Int16> aSeq = getSubTotals(); + uno::Sequence<sheet::GeneralFunction> aNewSeq; + aNewSeq.realloc(aSeq.getLength()); + for (sal_Int32 nIndex = 0; nIndex < aSeq.getLength(); nIndex++) + { + if (aSeq[nIndex] == sheet::GeneralFunction2::MEDIAN) + aNewSeq[nIndex] = sheet::GeneralFunction_NONE; + else + aNewSeq[nIndex] = static_cast<sheet::GeneralFunction>(aSeq[nIndex]); + } + + aRet <<= aNewSeq; + } + else if ( aPropertyName == SC_UNO_DP_SUBTOTAL2 ) + { + uno::Sequence<sal_Int16> aSeq = getSubTotals(); //TODO: avoid extra copy? aRet <<= aSeq; } else if ( aPropertyName == SC_UNO_DP_SORTING ) diff --git a/sc/source/core/data/dputil.cxx b/sc/source/core/data/dputil.cxx index d64a5a8dbf67..c2c4e46b02ec 100644 --- a/sc/source/core/data/dputil.cxx +++ b/sc/source/core/data/dputil.cxx @@ -22,6 +22,7 @@ #include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp> #include <com/sun/star/i18n/CalendarDisplayIndex.hpp> +#include <com/sun/star/sheet/GeneralFunction2.hpp> using namespace com::sun::star; @@ -410,10 +411,6 @@ ScSubTotalFunc ScDPUtil::toSubTotalFunc(css::sheet::GeneralFunction eGenFunc) 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; -#if 0 -// disabled because of css::sheet::GeneralFunction API incompatibility - case sheet::GeneralFunction_MEDIAN: eSubTotal = SUBTOTAL_FUNC_MED; break; -#endif 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; @@ -429,4 +426,29 @@ ScSubTotalFunc ScDPUtil::toSubTotalFunc(css::sheet::GeneralFunction eGenFunc) 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; + default: + assert(false); + } + return eSubTotal; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx index 090e49255c82..0e4245cd74a2 100644 --- a/sc/source/core/tool/interpr2.cxx +++ b/sc/source/core/tool/interpr2.cxx @@ -3657,7 +3657,7 @@ void ScInterpreter::ScGetPivotData() if (bOldSyntax) { OUString aFilterStr = aDataFieldName; - std::vector<sheet::GeneralFunction> aFilterFuncs; + std::vector<sal_Int16> aFilterFuncs; if (!pDPObj->ParseFilters(aDataFieldName, aFilters, aFilterFuncs, aFilterStr)) { PushError(FormulaError::NoRef); diff --git a/sc/source/filter/xml/XMLConverter.cxx b/sc/source/filter/xml/XMLConverter.cxx index 3c1688036ad9..2437a6e49444 100644 --- a/sc/source/filter/xml/XMLConverter.cxx +++ b/sc/source/filter/xml/XMLConverter.cxx @@ -19,6 +19,7 @@ #include "XMLConverter.hxx" #include <com/sun/star/util/DateTime.hpp> +#include <com/sun/star/sheet/GeneralFunction2.hpp> #include <tools/datetime.hxx> #include <sax/tools/converter.hxx> #include <xmloff/xmltoken.hxx> @@ -56,11 +57,6 @@ sheet::GeneralFunction ScXMLConverter::GetFunctionFromString( const OUString& sF return sheet::GeneralFunction_PRODUCT; if( IsXMLToken(sFunction, XML_AVERAGE ) ) return sheet::GeneralFunction_AVERAGE; -#if 0 -// disabled because of css::sheet::GeneralFunction API incompatibility - if( IsXMLToken(sFunction, XML_MEDIAN ) ) - return sheet::GeneralFunction_MEDIAN; -#endif if( IsXMLToken(sFunction, XML_MAX ) ) return sheet::GeneralFunction_MAX; if( IsXMLToken(sFunction, XML_MIN ) ) @@ -76,6 +72,37 @@ sheet::GeneralFunction ScXMLConverter::GetFunctionFromString( const OUString& sF return sheet::GeneralFunction_NONE; } +sal_Int16 ScXMLConverter::GetFunctionFromString2( const OUString& sFunction ) +{ + if( IsXMLToken(sFunction, XML_SUM ) ) + return sheet::GeneralFunction2::SUM; + if( IsXMLToken(sFunction, XML_AUTO ) ) + return sheet::GeneralFunction2::AUTO; + if( IsXMLToken(sFunction, XML_COUNT ) ) + return sheet::GeneralFunction2::COUNT; + if( IsXMLToken(sFunction, XML_COUNTNUMS ) ) + return sheet::GeneralFunction2::COUNTNUMS; + if( IsXMLToken(sFunction, XML_PRODUCT ) ) + return sheet::GeneralFunction2::PRODUCT; + if( IsXMLToken(sFunction, XML_AVERAGE ) ) + return sheet::GeneralFunction2::AVERAGE; + if( IsXMLToken(sFunction, XML_MEDIAN ) ) + return sheet::GeneralFunction2::MEDIAN; + if( IsXMLToken(sFunction, XML_MAX ) ) + return sheet::GeneralFunction2::MAX; + if( IsXMLToken(sFunction, XML_MIN ) ) + return sheet::GeneralFunction2::MIN; + if( IsXMLToken(sFunction, XML_STDEV ) ) + return sheet::GeneralFunction2::STDEV; + if( IsXMLToken(sFunction, XML_STDEVP ) ) + return sheet::GeneralFunction2::STDEVP; + if( IsXMLToken(sFunction, XML_VAR ) ) + return sheet::GeneralFunction2::VAR; + if( IsXMLToken(sFunction, XML_VARP ) ) + return sheet::GeneralFunction2::VARP; + return sheet::GeneralFunction2::NONE; +} + ScSubTotalFunc ScXMLConverter::GetSubTotalFuncFromString( const OUString& sFunction ) { if( IsXMLToken(sFunction, XML_SUM ) ) @@ -107,28 +134,25 @@ ScSubTotalFunc ScXMLConverter::GetSubTotalFuncFromString( const OUString& sFunct void ScXMLConverter::GetStringFromFunction( OUString& rString, - const sheet::GeneralFunction eFunction ) + sal_Int16 eFunction ) { OUString sFuncStr; switch( eFunction ) { - case sheet::GeneralFunction_AUTO: sFuncStr = GetXMLToken( XML_AUTO ); break; - case sheet::GeneralFunction_AVERAGE: sFuncStr = GetXMLToken( XML_AVERAGE ); break; -#if 0 -// disabled because of css::sheet::GeneralFunction API incompatibility - case sheet::GeneralFunction_MEDIAN: sFuncStr = GetXMLToken( XML_MEDIAN ); break; -#endif - case sheet::GeneralFunction_COUNT: sFuncStr = GetXMLToken( XML_COUNT ); break; - case sheet::GeneralFunction_COUNTNUMS: sFuncStr = GetXMLToken( XML_COUNTNUMS ); break; - case sheet::GeneralFunction_MAX: sFuncStr = GetXMLToken( XML_MAX ); break; - case sheet::GeneralFunction_MIN: sFuncStr = GetXMLToken( XML_MIN ); break; - case sheet::GeneralFunction_NONE: sFuncStr = GetXMLToken( XML_NONE ); break; - case sheet::GeneralFunction_PRODUCT: sFuncStr = GetXMLToken( XML_PRODUCT ); break; - case sheet::GeneralFunction_STDEV: sFuncStr = GetXMLToken( XML_STDEV ); break; - case sheet::GeneralFunction_STDEVP: sFuncStr = GetXMLToken( XML_STDEVP ); break; - case sheet::GeneralFunction_SUM: sFuncStr = GetXMLToken( XML_SUM ); break; - case sheet::GeneralFunction_VAR: sFuncStr = GetXMLToken( XML_VAR ); break; - case sheet::GeneralFunction_VARP: sFuncStr = GetXMLToken( XML_VARP ); break; + case sheet::GeneralFunction2::AUTO: sFuncStr = GetXMLToken( XML_AUTO ); break; + case sheet::GeneralFunction2::AVERAGE: sFuncStr = GetXMLToken( XML_AVERAGE ); break; + case sheet::GeneralFunction2::MEDIAN: sFuncStr = GetXMLToken( XML_MEDIAN ); break; + case sheet::GeneralFunction2::COUNT: sFuncStr = GetXMLToken( XML_COUNT ); break; + case sheet::GeneralFunction2::COUNTNUMS: sFuncStr = GetXMLToken( XML_COUNTNUMS ); break; + case sheet::GeneralFunction2::MAX: sFuncStr = GetXMLToken( XML_MAX ); break; + case sheet::GeneralFunction2::MIN: sFuncStr = GetXMLToken( XML_MIN ); break; + case sheet::GeneralFunction2::NONE: sFuncStr = GetXMLToken( XML_NONE ); break; + case sheet::GeneralFunction2::PRODUCT: sFuncStr = GetXMLToken( XML_PRODUCT ); break; + case sheet::GeneralFunction2::STDEV: sFuncStr = GetXMLToken( XML_STDEV ); break; + case sheet::GeneralFunction2::STDEVP: sFuncStr = GetXMLToken( XML_STDEVP ); break; + case sheet::GeneralFunction2::SUM: sFuncStr = GetXMLToken( XML_SUM ); break; + case sheet::GeneralFunction2::VAR: sFuncStr = GetXMLToken( XML_VAR ); break; + case sheet::GeneralFunction2::VARP: sFuncStr = GetXMLToken( XML_VARP ); break; default: { assert(false); diff --git a/sc/source/filter/xml/XMLConverter.hxx b/sc/source/filter/xml/XMLConverter.hxx index 8c8ffe542865..41535c357136 100644 --- a/sc/source/filter/xml/XMLConverter.hxx +++ b/sc/source/filter/xml/XMLConverter.hxx @@ -47,13 +47,16 @@ public: static css::sheet::GeneralFunction GetFunctionFromString( const OUString& rString ); + static sal_Int16 GetFunctionFromString2( + const OUString& rString ); + static ScSubTotalFunc GetSubTotalFuncFromString( const OUString& rString ); -// EXPORT: GeneralFunction / ScSubTotalFunc +// EXPORT: GeneralFunctio2 / ScSubTotalFunc static void GetStringFromFunction( OUString& rString, - const css::sheet::GeneralFunction eFunction ); + const sal_Int16 eFunction ); static void GetStringFromFunction( OUString& rString, const ScSubTotalFunc eFunction ); diff --git a/sc/source/filter/xml/XMLExportDataPilot.cxx b/sc/source/filter/xml/XMLExportDataPilot.cxx index aa461163755a..b16aa0a03143 100644 --- a/sc/source/filter/xml/XMLExportDataPilot.cxx +++ b/sc/source/filter/xml/XMLExportDataPilot.cxx @@ -51,6 +51,7 @@ #include <com/sun/star/sheet/DataPilotFieldSortMode.hpp> #include <com/sun/star/sheet/DataPilotFieldLayoutMode.hpp> #include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp> +#include <com/sun/star/sheet/GeneralFunction2.hpp> using namespace com::sun::star; using namespace xmloff::token; @@ -431,8 +432,6 @@ void ScXMLExportDataPilot::WriteLayoutInfo(ScDPSaveDimension* pDim) void ScXMLExportDataPilot::WriteSubTotals(ScDPSaveDimension* pDim) { - using sheet::GeneralFunction; - sal_Int32 nSubTotalCount = pDim->GetSubTotalsCount(); const OUString* pLayoutName = nullptr; if (rExport.getDefaultVersion() > SvtSaveOptions::ODFVER_012) @@ -446,10 +445,10 @@ void ScXMLExportDataPilot::WriteSubTotals(ScDPSaveDimension* pDim) for (sal_Int32 nSubTotal = 0; nSubTotal < nSubTotalCount; nSubTotal++) { OUString sFunction; - GeneralFunction nFunc = static_cast<GeneralFunction>(pDim->GetSubTotalFunc(nSubTotal)); + sal_Int16 nFunc = static_cast<sal_Int16>(pDim->GetSubTotalFunc(nSubTotal)); ScXMLConverter::GetStringFromFunction( sFunction, nFunc); rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_FUNCTION, sFunction); - if (pLayoutName && nFunc == sheet::GeneralFunction_AUTO) + if (pLayoutName && nFunc == sheet::GeneralFunction2::AUTO) rExport.AddAttribute(XML_NAMESPACE_TABLE_EXT, XML_DISPLAY_NAME, *pLayoutName); SvXMLElementExport aElemST(rExport, XML_NAMESPACE_TABLE, XML_DATA_PILOT_SUBTOTAL, true, true); } @@ -699,8 +698,7 @@ void ScXMLExportDataPilot::WriteDimension(ScDPSaveDimension* pDim, const ScDPDim ::sax::Converter::convertNumber(sBuffer, pDim->GetUsedHierarchy()); rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_USED_HIERARCHY, sBuffer.makeStringAndClear()); } - ScXMLConverter::GetStringFromFunction( sValueStr, - (sheet::GeneralFunction) pDim->GetFunction() ); + ScXMLConverter::GetStringFromFunction( sValueStr, static_cast<sal_Int16>(pDim->GetFunction()) ); rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_FUNCTION, sValueStr); if (eOrientation == sheet::DataPilotFieldOrientation_PAGE) diff --git a/sc/source/filter/xml/xmldpimp.cxx b/sc/source/filter/xml/xmldpimp.cxx index 19b84729c4d4..cc39b95ce0aa 100644 --- a/sc/source/filter/xml/xmldpimp.cxx +++ b/sc/source/filter/xml/xmldpimp.cxx @@ -994,7 +994,7 @@ ScXMLDataPilotFieldContext::ScXMLDataPilotFieldContext( ScXMLImport& rImport, break; case XML_TOK_DATA_PILOT_FIELD_ATTR_FUNCTION : { - nFunction = (sal_Int16) ScXMLConverter::GetFunctionFromString( sValue ); + nFunction = ScXMLConverter::GetFunctionFromString2( sValue ); } break; case XML_TOK_DATA_PILOT_FIELD_ATTR_ORIENTATION : @@ -1522,8 +1522,7 @@ ScXMLDataPilotSubTotalContext::ScXMLDataPilotSubTotalContext( ScXMLImport& rImpo { case XML_TOK_DATA_PILOT_SUBTOTAL_ATTR_FUNCTION : { - pDataPilotSubTotals->AddFunction( sal::static_int_cast<sal_Int16>( - ScXMLConverter::GetFunctionFromString( sValue ) ) ); + pDataPilotSubTotals->AddFunction( ScXMLConverter::GetFunctionFromString2( sValue ) ); } break; case XML_TOK_DATA_PILOT_SUBTOTAL_ATTR_DISPLAY_NAME: diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx index a09053b4d865..dca44793609e 100644 --- a/sc/source/ui/unoobj/dapiuno.cxx +++ b/sc/source/ui/unoobj/dapiuno.cxx @@ -50,6 +50,7 @@ #include <com/sun/star/sheet/DataPilotFieldFilter.hpp> #include <com/sun/star/sheet/DataPilotOutputRangeType.hpp> #include <com/sun/star/sheet/DataPilotTablePositionData.hpp> +#include <com/sun/star/sheet/GeneralFunction2.hpp> #include <comphelper/extract.hxx> #include <comphelper/sequence.hxx> @@ -115,6 +116,7 @@ const SfxItemPropertyMapEntry* lcl_GetDataPilotFieldMap() { {OUString(SC_UNONAME_AUTOSHOW), 0, cppu::UnoType<DataPilotFieldAutoShowInfo>::get(), MAYBEVOID, 0 }, {OUString(SC_UNONAME_FUNCTION), 0, cppu::UnoType<GeneralFunction>::get(), 0, 0 }, + {OUString(SC_UNONAME_FUNCTION2), 0, cppu::UnoType<sal_Int16>::get(), 0, 0 }, {OUString(SC_UNONAME_GROUPINFO), 0, cppu::UnoType<DataPilotFieldGroupInfo>::get(), MAYBEVOID, 0 }, {OUString(SC_UNONAME_HASAUTOSHOW), 0, cppu::UnoType<bool>::get(), 0, 0 }, {OUString(SC_UNONAME_HASLAYOUTINFO),0, cppu::UnoType<bool>::get(), 0, 0 }, @@ -129,6 +131,7 @@ const SfxItemPropertyMapEntry* lcl_GetDataPilotFieldMap() {OUString(SC_UNONAME_REPEATITEMLABELS), 0, cppu::UnoType<bool>::get(), 0, 0 }, {OUString(SC_UNONAME_SORTINFO), 0, cppu::UnoType<DataPilotFieldSortInfo>::get(), MAYBEVOID, 0 }, {OUString(SC_UNONAME_SUBTOTALS), 0, cppu::UnoType<Sequence<GeneralFunction>>::get(), 0, 0 }, + {OUString(SC_UNONAME_SUBTOTALS2), 0, cppu::UnoType<Sequence<sal_Int16>>::get(), 0, 0 }, {OUString(SC_UNONAME_USESELPAGE), 0, cppu::UnoType<bool>::get(), 0, 0 }, { OUString(), 0, css::uno::Type(), 0, 0 } }; @@ -179,48 +182,42 @@ SC_SIMPLE_SERVICE_INFO( ScDataPilotFieldGroupItemObj, "ScDataPilotFieldGroupItem // name that is used in the API for the data layout field #define SC_DATALAYOUT_NAME "Data" -GeneralFunction ScDataPilotConversion::FirstFunc( PivotFunc nBits ) -{ - if ( nBits & PivotFunc::Sum ) return GeneralFunction_SUM; - if ( nBits & PivotFunc::Count ) return GeneralFunction_COUNT; - if ( nBits & PivotFunc::Average ) return GeneralFunction_AVERAGE; -#if 0 -// disabled because of css::sheet::GeneralFunction API incompatibility - if ( nBits & PivotFunc::Median ) return GeneralFunction_MEDIAN; -#endif - if ( nBits & PivotFunc::Max ) return GeneralFunction_MAX; - if ( nBits & PivotFunc::Min ) return GeneralFunction_MIN; - if ( nBits & PivotFunc::Product ) return GeneralFunction_PRODUCT; - if ( nBits & PivotFunc::CountNum ) return GeneralFunction_COUNTNUMS; - if ( nBits & PivotFunc::StdDev ) return GeneralFunction_STDEV; - if ( nBits & PivotFunc::StdDevP ) return GeneralFunction_STDEVP; - if ( nBits & PivotFunc::StdVar ) return GeneralFunction_VAR; - if ( nBits & PivotFunc::StdVarP ) return GeneralFunction_VARP; - if ( nBits & PivotFunc::Auto ) return GeneralFunction_AUTO; - return GeneralFunction_NONE; -} - -PivotFunc ScDataPilotConversion::FunctionBit( GeneralFunction eFunc ) +sal_Int16 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; +} + +PivotFunc ScDataPilotConversion::FunctionBit( sal_Int16 eFunc ) { PivotFunc nRet = PivotFunc::NONE; // 0 switch (eFunc) { - case GeneralFunction_SUM: nRet = PivotFunc::Sum; break; - case GeneralFunction_COUNT: nRet = PivotFunc::Count; break; - case GeneralFunction_AVERAGE: nRet = PivotFunc::Average; break; -#if 0 -// disabled because of css::sheet::GeneralFunction API incompatibility - case GeneralFunction_MEDIAN: nRet = PivotFunc::Median; break; -#endif - case GeneralFunction_MAX: nRet = PivotFunc::Max; break; - case GeneralFunction_MIN: nRet = PivotFunc::Min; break; - case GeneralFunction_PRODUCT: nRet = PivotFunc::Product; break; - case GeneralFunction_COUNTNUMS: nRet = PivotFunc::CountNum; break; - case GeneralFunction_STDEV: nRet = PivotFunc::StdDev; break; - case GeneralFunction_STDEVP: nRet = PivotFunc::StdDevP; break; - case GeneralFunction_VAR: nRet = PivotFunc::StdVar; break; - case GeneralFunction_VARP: nRet = PivotFunc::StdVarP; break; - case GeneralFunction_AUTO: nRet = PivotFunc::Auto; break; + case GeneralFunction2::SUM: nRet = PivotFunc::Sum; break; + case GeneralFunction2::COUNT: nRet = PivotFunc::Count; break; + case GeneralFunction2::AVERAGE: nRet = PivotFunc::Average; break; + case GeneralFunction2::MEDIAN: nRet = PivotFunc::Median; break; + case GeneralFunction2::MAX: nRet = PivotFunc::Max; break; + case GeneralFunction2::MIN: nRet = PivotFunc::Min; break; + case GeneralFunction2::PRODUCT: nRet = PivotFunc::Product; break; + case GeneralFunction2::COUNTNUMS: nRet = PivotFunc::CountNum; break; + case GeneralFunction2::STDEV: nRet = PivotFunc::StdDev; break; + case GeneralFunction2::STDEVP: nRet = PivotFunc::StdDevP; break; + case GeneralFunction2::VAR: nRet = PivotFunc::StdVar; break; + case GeneralFunction2::VARP: nRet = PivotFunc::StdVarP; break; + case GeneralFunction2::AUTO: nRet = PivotFunc::Auto; break; default: { assert(false); @@ -1868,11 +1865,30 @@ void SAL_CALL ScDataPilotFieldObj::setPropertyValue( const OUString& aPropertyNa // #i109350# use GetEnumFromAny because it also allows sal_Int32 GeneralFunction eFunction = (GeneralFunction) ScUnoHelpFunctions::GetEnumFromAny( aValue ); + setFunction( static_cast<sal_Int16> (eFunction) ); + } + else if ( aPropertyName == SC_UNONAME_FUNCTION2 ) + { + sal_Int16 eFunction = (sal_Int16) ScUnoHelpFunctions::GetEnumFromAny( aValue ); setFunction( eFunction ); } else if ( aPropertyName == SC_UNONAME_SUBTOTALS ) { - Sequence< GeneralFunction > aSubtotals; + Sequence< sal_Int16 > aSubTotals; + uno::Sequence<sheet::GeneralFunction> aSeq; + if( aValue >>= aSeq) + { + aSubTotals.realloc(aSeq.getLength()); + for (sal_Int32 nIndex = 0; nIndex < aSeq.getLength(); nIndex++) + { + aSubTotals[nIndex] = static_cast<sal_Int16>(aSeq[nIndex]); + } + setSubtotals( aSubTotals ); + } + } + else if ( aPropertyName == SC_UNONAME_SUBTOTALS2 ) + { + Sequence< sal_Int16 > aSubtotals; if( aValue >>= aSubtotals ) setSubtotals( aSubtotals ); } @@ -1966,9 +1982,39 @@ Any SAL_CALL ScDataPilotFieldObj::getPropertyValue( const OUString& aPropertyNam Any aRet; if ( aPropertyName == SC_UNONAME_FUNCTION ) + { + sheet::GeneralFunction eVal; + sal_Int16 nFunction = getFunction(); + if (nFunction == sheet::GeneralFunction2::MEDIAN) + { + eVal = sheet::GeneralFunction_NONE; + } + else + { + eVal = static_cast<sheet::GeneralFunction>(nFunction); + } + aRet <<= eVal; + } + else if ( aPropertyName == SC_UNONAME_FUNCTION2 ) aRet <<= getFunction(); else if ( aPropertyName == SC_UNONAME_SUBTOTALS ) + { + uno::Sequence<sal_Int16> aSeq = getSubtotals(); + uno::Sequence<sheet::GeneralFunction> aNewSeq; + aNewSeq.realloc(aSeq.getLength()); + for (sal_Int32 nIndex = 0; nIndex < aSeq.getLength(); nIndex++) + { + if (aSeq[nIndex] == sheet::GeneralFunction2::MEDIAN) + aNewSeq[nIndex] = sheet::GeneralFunction_NONE; + else + aNewSeq[nIndex] = static_cast<sheet::GeneralFunction>(aSeq[nIndex]); + } + aRet <<= aNewSeq; + } + else if ( aPropertyName == SC_UNONAME_SUBTOTALS2 ) + { aRet <<= getSubtotals(); + } else if ( aPropertyName == SC_UNONAME_ORIENT ) aRet <<= getOrientation(); else if ( aPropertyName == SC_UNONAME_SELPAGE ) @@ -2098,10 +2144,10 @@ void ScDataPilotFieldObj::setOrientation(DataPilotFieldOrientation eNew) } } -GeneralFunction ScDataPilotFieldObj::getFunction() const +sal_Int16 ScDataPilotFieldObj::getFunction() const { SolarMutexGuard aGuard; - GeneralFunction eRet = GeneralFunction_NONE; + sal_Int16 eRet = GeneralFunction2::NONE; if( ScDPSaveDimension* pDim = GetDPDimension() ) { if( pDim->GetOrientation() != DataPilotFieldOrientation_DATA ) @@ -2109,16 +2155,16 @@ GeneralFunction ScDataPilotFieldObj::getFunction() const // for non-data fields, property Function is the subtotals long nSubCount = pDim->GetSubTotalsCount(); if ( nSubCount > 0 ) - eRet = (GeneralFunction)pDim->GetSubTotalFunc(0); // always use the first one + eRet = static_cast<sal_Int16>(pDim->GetSubTotalFunc(0)); // always use the first one // else keep NONE } else - eRet = (GeneralFunction)pDim->GetFunction(); + eRet = static_cast<sal_Int16>(pDim->GetFunction()); } return eRet; } -void ScDataPilotFieldObj::setFunction(GeneralFunction eNewFunc) +void ScDataPilotFieldObj::setFunction(sal_Int16 eNewFunc) { SolarMutexGuard aGuard; ScDPObject* pDPObj = nullptr; @@ -2127,7 +2173,7 @@ void ScDataPilotFieldObj::setFunction(GeneralFunction eNewFunc) if( pDim->GetOrientation() != DataPilotFieldOrientation_DATA ) { // for non-data fields, property Function is the subtotals - if ( eNewFunc == GeneralFunction_NONE ) + if ( eNewFunc == GeneralFunction2::NONE ) pDim->SetSubTotals( 0, nullptr ); else { @@ -2141,10 +2187,10 @@ void ScDataPilotFieldObj::setFunction(GeneralFunction eNewFunc) } } -Sequence< GeneralFunction > ScDataPilotFieldObj::getSubtotals() const +Sequence< sal_Int16 > ScDataPilotFieldObj::getSubtotals() const { SolarMutexGuard aGuard; - Sequence< GeneralFunction > aRet; + Sequence< sal_Int16 > aRet; if( ScDPSaveDimension* pDim = GetDPDimension() ) { if( pDim->GetOrientation() != DataPilotFieldOrientation_DATA ) @@ -2155,14 +2201,14 @@ Sequence< GeneralFunction > ScDataPilotFieldObj::getSubtotals() const { aRet.realloc( nCount ); for( sal_Int32 nIdx = 0; nIdx < nCount; ++nIdx ) - aRet[ nIdx ] = (GeneralFunction)pDim->GetSubTotalFunc( nIdx ); + aRet[ nIdx ] = static_cast<sal_Int16>(pDim->GetSubTotalFunc( nIdx )); } } } return aRet; } -void ScDataPilotFieldObj::setSubtotals( const Sequence< GeneralFunction >& rSubtotals ) +void ScDataPilotFieldObj::setSubtotals( const Sequence< sal_Int16 >& rSubtotals ) { SolarMutexGuard aGuard; ScDPObject* pDPObj = nullptr; @@ -2174,7 +2220,7 @@ void ScDataPilotFieldObj::setSubtotals( const Sequence< GeneralFunction >& rSubt if( nCount == 1 ) { // count 1: all values are allowed (including NONE and AUTO) - if( rSubtotals[ 0 ] == GeneralFunction_NONE ) + if( rSubtotals[ 0 ] == GeneralFunction2::NONE ) pDim->SetSubTotals( 0, nullptr ); else { @@ -2188,8 +2234,8 @@ void ScDataPilotFieldObj::setSubtotals( const Sequence< GeneralFunction >& rSubt ::std::vector< sal_uInt16 > aSubt; for( sal_Int32 nIdx = 0; nIdx < nCount; ++nIdx ) { - GeneralFunction eFunc = rSubtotals[ nIdx ]; - if( (eFunc != GeneralFunction_NONE) && (eFunc != GeneralFunction_AUTO) ) + sal_Int16 eFunc = rSubtotals[ nIdx ]; + if( (eFunc != GeneralFunction2::NONE) && (eFunc != GeneralFunction2::AUTO) ) { // do not insert functions twice sal_uInt16 nFunc = static_cast< sal_uInt16 >( eFunc ); diff --git a/sc/source/ui/unoobj/datauno.cxx b/sc/source/ui/unoobj/datauno.cxx index 63c5a864c7cb..718af054bfcb 100644 --- a/sc/source/ui/unoobj/datauno.cxx +++ b/sc/source/ui/unoobj/datauno.cxx @@ -144,12 +144,6 @@ sheet::GeneralFunction ScDataUnoConversion::SubTotalToGeneral( ScSubTotalFunc e case SUBTOTAL_FUNC_AVE: eGeneral = sheet::GeneralFunction_AVERAGE; break; case SUBTOTAL_FUNC_CNT: eGeneral = sheet::GeneralFunction_COUNTNUMS; break; case SUBTOTAL_FUNC_CNT2: eGeneral = sheet::GeneralFunction_COUNT; break; -#if 0 -// disabled because of css::sheet::GeneralFunction API incompatibility - case SUBTOTAL_FUNC_MED: eGeneral = sheet::GeneralFunction_MEDIAN; break; -#else - case SUBTOTAL_FUNC_MED: eGeneral = sheet::GeneralFunction_NONE; break; -#endif case SUBTOTAL_FUNC_MAX: eGeneral = sheet::GeneralFunction_MAX; break; case SUBTOTAL_FUNC_MIN: eGeneral = sheet::GeneralFunction_MIN; break; case SUBTOTAL_FUNC_PROD: eGeneral = sheet::GeneralFunction_PRODUCT; break; |