From f8daf04a1d06f870202a1f1868b59ce90adde0e4 Mon Sep 17 00:00:00 2001 From: Tamás Zolnai Date: Wed, 23 Nov 2016 04:50:02 +0000 Subject: [API Change]: Create new GeneralFunction2 for adding median MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New functionality added to pivot table became fully broken with Eike's revertion: 50244309501d738e7314fa79785db139c826f8d7 This commit fixes this problem. Reviewed-on: https://gerrit.libreoffice.org/31096 Reviewed-by: Tamás Zolnai Tested-by: Tamás Zolnai (cherry picked from commit c0d4aadf08c16f2d79508367c631366f7a856346) GeneralFunction is not an enum anymore Reviewed-on: https://gerrit.libreoffice.org/31103 Reviewed-by: Tamás Zolnai Tested-by: Tamás Zolnai (cherry picked from commit 5b7b2c8649596299c8f00b8b3b5056d272e25ccd) Change-Id: I67cfc63305bb9b2edeed2abd26d729fbf650579f Reviewed-on: https://gerrit.libreoffice.org/31099 Reviewed-by: Tamás Zolnai Tested-by: Tamás Zolnai --- offapi/UnoApi_offapi.mk | 1 + offapi/com/sun/star/sheet/DataPilotField.idl | 32 ++++- .../sun/star/sheet/DataPilotSourceDimension.idl | 6 + offapi/com/sun/star/sheet/DataPilotSourceLevel.idl | 7 + offapi/com/sun/star/sheet/GeneralFunction2.idl | 111 +++++++++++++++ sc/inc/dapiuno.hxx | 13 +- sc/inc/dpobject.hxx | 2 +- sc/inc/dpoutput.hxx | 1 - sc/inc/dpsave.hxx | 4 +- sc/inc/dptabsrc.hxx | 7 +- sc/inc/dputil.hxx | 1 + sc/inc/miscuno.hxx | 2 + sc/inc/unonames.hxx | 4 + sc/qa/extras/check_data_pilot_field.cxx | 4 +- sc/qa/unit/subsequent_export-test.cxx | 18 +-- sc/qa/unit/subsequent_filters-test.cxx | 4 +- sc/source/core/data/dpobject.cxx | 64 ++++----- sc/source/core/data/dpoutput.cxx | 40 +++--- sc/source/core/data/dpsave.cxx | 15 ++- sc/source/core/data/dptabres.cxx | 13 +- sc/source/core/data/dptabsrc.cxx | 66 +++++++-- sc/source/core/data/dputil.cxx | 30 ++++- sc/source/core/tool/interpr2.cxx | 2 +- sc/source/filter/xml/XMLConverter.cxx | 70 ++++++---- sc/source/filter/xml/XMLConverter.hxx | 7 +- sc/source/filter/xml/XMLExportDataPilot.cxx | 10 +- sc/source/filter/xml/xmldpimp.cxx | 5 +- sc/source/ui/unoobj/dapiuno.cxx | 150 ++++++++++++++------- sc/source/ui/unoobj/datauno.cxx | 6 - sc/source/ui/unoobj/miscuno.cxx | 18 +++ 30 files changed, 509 insertions(+), 204 deletions(-) create mode 100644 offapi/com/sun/star/sheet/GeneralFunction2.idl diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk index b5657f7f4ae1..c53b2d938392 100644 --- a/offapi/UnoApi_offapi.mk +++ b/offapi/UnoApi_offapi.mk @@ -3409,6 +3409,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/sheet,\ FunctionArgument \ FunctionCategory \ GeneralFunction \ + GeneralFunction2 \ GoalResult \ IconSetFormatEntry \ IconSetType \ diff --git a/offapi/com/sun/star/sheet/DataPilotField.idl b/offapi/com/sun/star/sheet/DataPilotField.idl index edc84ae67ddf..b9f6b2b5c8d2 100644 --- a/offapi/com/sun/star/sheet/DataPilotField.idl +++ b/offapi/com/sun/star/sheet/DataPilotField.idl @@ -98,7 +98,6 @@ published service DataPilotField */ [property, optional] sequence Subtotals; - /** specifies the selected page which is used to filter the data pilot. */ [property, optional] string SelectedPage; @@ -175,6 +174,37 @@ published service DataPilotField /** specifies whether to show this field also if it is empty or not. */ [property, optional] boolean ShowEmpty; + + /** specifies the function used to calculate results for this field. + +

For column and row fields, this is the function for subtotals + (GeneralFunction2::NONE means no subtotals). + For data fields, this is the function shown in the data pilot + table.

+ + @since LibreOffice 5.3 + */ + + [property, optional] short Function2; + + /** specifies the functions used to calculate subtotals for this field. + +

This property is supported by column and row fields only.

+ +

An empty sequence means no subtotals. The same effect can be + achieved by setting the property #Function2 to the + value GeneralFunction::NONE. If the length of the + sequence is greater then 1, then the sequence MUST NOT contain one of + the values GeneralFunction2::NONE or + GeneralFunction2::AUTO.

+ +

The order of the functions in this sequence is reflected in the + DataPilot table. Multiple entries of the same function are ignored + when setting the property.

+ + @since LibreOffice 5.3 + */ + [property, optional] sequence Subtotals2; }; diff --git a/offapi/com/sun/star/sheet/DataPilotSourceDimension.idl b/offapi/com/sun/star/sheet/DataPilotSourceDimension.idl index 2309d172e9ef..5ef61f5083eb 100644 --- a/offapi/com/sun/star/sheet/DataPilotSourceDimension.idl +++ b/offapi/com/sun/star/sheet/DataPilotSourceDimension.idl @@ -122,6 +122,12 @@ service DataPilotSourceDimension */ [readonly, property, optional] long Flags; + + /** specifies how data are aggregated. + @since LibreOffice 5.3 + */ + [property, optional] short Function2; + }; diff --git a/offapi/com/sun/star/sheet/DataPilotSourceLevel.idl b/offapi/com/sun/star/sheet/DataPilotSourceLevel.idl index d7fb274fd80f..2485de51778a 100644 --- a/offapi/com/sun/star/sheet/DataPilotSourceLevel.idl +++ b/offapi/com/sun/star/sheet/DataPilotSourceLevel.idl @@ -70,6 +70,13 @@ service DataPilotSourceLevel */ [property] boolean ShowEmpty; + + /** specifies the subtotals that are inserted for the level. + +

The subtotals are calculated with the members of this level.

+ @since LibreOffice 5.3 + */ + [property, optional] sequence< short > SubTotals2; }; diff --git a/offapi/com/sun/star/sheet/GeneralFunction2.idl b/offapi/com/sun/star/sheet/GeneralFunction2.idl new file mode 100644 index 000000000000..926f7b174d73 --- /dev/null +++ b/offapi/com/sun/star/sheet/GeneralFunction2.idl @@ -0,0 +1,111 @@ +/* -*- 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 __com_sun_star_sheet_GeneralFunction2_idl__ +#define __com_sun_star_sheet_GeneralFunction2_idl__ + + +module com { module sun { module star { module sheet { + + +/** used to specify a function to be calculated from values. + @since LibreOffice 5.3 + */ +published constants GeneralFunction2 +{ + + /** nothing is calculated. + */ + const short NONE = 0; + + + /** function is determined automatically. + +

If the values are all numerical, SUM is used, otherwise COUNT.

+ */ + const short AUTO = 1; + + + /** sum of all numerical values is calculated. + */ + const short SUM = 2; + + + /** all values, including non-numerical values, are counted. + */ + const short COUNT = 3; + + + /** average of all numerical values is calculated. + */ + const short AVERAGE = 4; + + + /** maximum value of all numerical values is calculated. + */ + const short MAX = 5; + + + /** minimum value of all numerical values is calculated. + */ + const short MIN = 6; + + + /** product of all numerical values is calculated. + */ + const short PRODUCT = 7; + + + /** numerical values are counted. + */ + const short COUNTNUMS = 8; + + + /** standard deviation is calculated based on a sample. + */ + const short STDEV = 9; + + + /** standard deviation is calculated based on the entire population. + */ + const short STDEVP = 10; + + + /** variance is calculated based on a sample. + */ + const short VAR = 11; + + + /** variance is calculated based on the entire population. + */ + const short VARP = 12; + + /** + * median of all numerical values is calculated. + * @since LibreOffice 5.3 + */ + const short MEDIAN = 13; +}; + + +}; }; }; }; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/dapiuno.hxx b/sc/inc/dapiuno.hxx index 915d9d90d40e..c8f7e88a72a1 100644 --- a/sc/inc/dapiuno.hxx +++ b/sc/inc/dapiuno.hxx @@ -41,7 +41,6 @@ #include #include #include -#include #include #include #include @@ -70,8 +69,8 @@ class ScDataPilotItemObj; class ScDataPilotConversion { public: - static css::sheet::GeneralFunction FirstFunc( PivotFunc nBits ); - static PivotFunc FunctionBit( css::sheet::GeneralFunction eFunc ); + static sal_Int16 FirstFunc( PivotFunc nBits ); + static PivotFunc FunctionBit( sal_Int16 eFunc ); static void FillGroupInfo( css::sheet::DataPilotFieldGroupInfo& rInfo, @@ -551,10 +550,10 @@ public: // only called from property-functions: css::sheet::DataPilotFieldOrientation getOrientation() const; void setOrientation(css::sheet::DataPilotFieldOrientation Orientation); - css::sheet::GeneralFunction getFunction() const; - void setFunction(css::sheet::GeneralFunction Function); - css::uno::Sequence< css::sheet::GeneralFunction > getSubtotals() const; - void setSubtotals(const css::uno::Sequence< css::sheet::GeneralFunction >& rFunctions); + sal_Int16 getFunction() const; + void setFunction(sal_Int16 Function); + css::uno::Sequence< sal_Int16 > getSubtotals() const; + void setSubtotals(const css::uno::Sequence< sal_Int16 >& rFunctions); void setCurrentPage(const OUString& sPage); void setUseCurrentPage(bool bUse); const css::sheet::DataPilotFieldAutoShowInfo* getAutoShowInfo(); diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx index befd3233f1a1..2f144c5c7786 100644 --- a/sc/inc/dpobject.hxx +++ b/sc/inc/dpobject.hxx @@ -186,7 +186,7 @@ public: bool ParseFilters( OUString& rDataFieldName, std::vector& rFilters, - std::vector& rFilterFuncs, + std::vector& rFilterFuncs, const OUString& rFilterList ); void GetMemberResultNames(ScDPUniqueStringSet& rNames, long nDimension); diff --git a/sc/inc/dpoutput.hxx b/sc/inc/dpoutput.hxx index 78bd6a6b1006..9f9fdcf308a5 100644 --- a/sc/inc/dpoutput.hxx +++ b/sc/inc/dpoutput.hxx @@ -23,7 +23,6 @@ #include #include #include -#include #include #include "global.hxx" diff --git a/sc/inc/dpsave.hxx b/sc/inc/dpsave.hxx index a264ce77b535..663bcb2d724d 100644 --- a/sc/inc/dpsave.hxx +++ b/sc/inc/dpsave.hxx @@ -98,13 +98,13 @@ private: bool bIsDataLayout; bool bDupFlag; sal_uInt16 nOrientation; - sal_uInt16 nFunction; // enum GeneralFunction, for data dimensions + sal_uInt16 nFunction; // GeneralFunction2, for data dimensions long nUsedHierarchy; sal_uInt16 nShowEmptyMode; //! at level bool bRepeatItemLabels; //! at level bool bSubTotalDefault; //! at level long nSubTotalCount; - sal_uInt16* pSubTotalFuncs; // enum GeneralFunction + sal_uInt16* pSubTotalFuncs; // GeneralFunction2 css::sheet::DataPilotFieldReference* pReferenceValue; css::sheet::DataPilotFieldSortInfo* pSortInfo; // (level) css::sheet::DataPilotFieldAutoShowInfo* pAutoShowInfo; // (level) diff --git a/sc/inc/dptabsrc.hxx b/sc/inc/dptabsrc.hxx index 3fca6ce07cc7..48c0714e915a 100644 --- a/sc/inc/dptabsrc.hxx +++ b/sc/inc/dptabsrc.hxx @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -307,7 +306,7 @@ class ScDPDimension : public cppu::WeakImplHelper< ScDPSource* pSource; long nDim; // dimension index (== column ID) rtl::Reference mxHierarchies; - sal_uInt16 nFunction; // enum GeneralFunction + sal_uInt16 nFunction; // enum GeneralFunction2 OUString aName; // if empty, take from source std::unique_ptr mpLayoutName; std::unique_ptr mpSubtotalName; @@ -538,7 +537,7 @@ private: long nHier; long nLev; rtl::Reference mxMembers; - css::uno::Sequence aSubTotals; + css::uno::Sequence aSubTotals; css::sheet::DataPilotFieldSortInfo aSortInfo; // stored user settings css::sheet::DataPilotFieldAutoShowInfo aAutoShowInfo; // stored user settings css::sheet::DataPilotFieldLayoutInfo aLayoutInfo; // stored user settings @@ -614,7 +613,7 @@ public: virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(css::uno::RuntimeException, std::exception) override; - css::uno::Sequence getSubTotals() const; + css::uno::Sequence getSubTotals() const; bool getShowEmpty() const { return bShowEmpty;} bool getRepeatItemLabels() const { return bRepeatItemLabels; } diff --git a/sc/inc/dputil.hxx b/sc/inc/dputil.hxx index 29c7036e0d0e..525e67363c9a 100644 --- a/sc/inc/dputil.hxx +++ b/sc/inc/dputil.hxx @@ -51,6 +51,7 @@ public: static OUString getDisplayedMeasureName(const OUString& rName, ScSubTotalFunc eFunc); static ScSubTotalFunc toSubTotalFunc(css::sheet::GeneralFunction eGenFunc); + static ScSubTotalFunc toSubTotalFunc(sal_Int16 eGenFunc); }; #endif diff --git a/sc/inc/miscuno.hxx b/sc/inc/miscuno.hxx index e453a0a57a3e..d939d77a6759 100644 --- a/sc/inc/miscuno.hxx +++ b/sc/inc/miscuno.hxx @@ -154,6 +154,8 @@ public: AnyToInterface( const css::uno::Any& rAny ); static bool GetBoolProperty( const css::uno::Reference< css::beans::XPropertySet>& xProp, const OUString& rName, bool bDefault = false ); + static sal_Int16 GetShortProperty( const css::uno::Reference< css::beans::XPropertySet>& xProp, + const OUString& rName, sal_Int16 nDefault ); static sal_Int32 GetLongProperty( const css::uno::Reference< css::beans::XPropertySet>& xProp, const OUString& rName ); static sal_Int32 GetEnumProperty( const css::uno::Reference< css::beans::XPropertySet>& xProp, diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx index e7ff39cbf595..469183d18b78 100644 --- a/sc/inc/unonames.hxx +++ b/sc/inc/unonames.hxx @@ -249,7 +249,9 @@ // data pilot field #define SC_UNONAME_FUNCTION "Function" +#define SC_UNONAME_FUNCTION2 "Function2" #define SC_UNONAME_SUBTOTALS "Subtotals" +#define SC_UNONAME_SUBTOTALS2 "Subtotals2" #define SC_UNONAME_SELPAGE "SelectedPage" #define SC_UNONAME_USESELPAGE "UseSelectedPage" #define SC_UNONAME_HASREFERENCE "HasReference" @@ -582,9 +584,11 @@ #define SC_UNO_DP_ORIENTATION "Orientation" #define SC_UNO_DP_POSITION "Position" #define SC_UNO_DP_FUNCTION "Function" +#define SC_UNO_DP_FUNCTION2 "Function2" #define SC_UNO_DP_USEDHIERARCHY "UsedHierarchy" #define SC_UNO_DP_FILTER "Filter" #define SC_UNO_DP_SUBTOTAL "SubTotals" +#define SC_UNO_DP_SUBTOTAL2 "SubTotals2" #define SC_UNO_DP_SHOWEMPTY "ShowEmpty" #define SC_UNO_DP_REPEATITEMLABELS "RepeatItemLabels" #define SC_UNO_DP_ISVISIBLE "IsVisible" diff --git a/sc/qa/extras/check_data_pilot_field.cxx b/sc/qa/extras/check_data_pilot_field.cxx index 24c7ffb90f9a..e4013727015a 100644 --- a/sc/qa/extras/check_data_pilot_field.cxx +++ b/sc/qa/extras/check_data_pilot_field.cxx @@ -69,7 +69,9 @@ private: bool CheckDataPilotField::isPropertyIgnored(const OUString& rName) { return rName == "Function" - || rName == "Subtotals"; + || rName == "Subtotals" + || rName == "Function2" + || rName == "Subtotals2"; } CheckDataPilotField::CheckDataPilotField() diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index 9b2441ab17fe..ab80b095db55 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -67,7 +67,7 @@ #include #include #include -#include +#include #include #include #include @@ -2787,7 +2787,7 @@ void ScExportTest::testPivotTableXLSX() } const ScDPSaveDimension* pDim = aDims[0]; - if (pDim->GetFunction() != sheet::GeneralFunction_SUM) + if (pDim->GetFunction() != sheet::GeneralFunction2::SUM) { cerr << "Data field should have SUM function." << endl; return false; @@ -2894,13 +2894,13 @@ void ScExportTest::testPivotTableTwoDataFieldsXLSX() return false; } - if (aDims[0]->GetFunction() != sheet::GeneralFunction_SUM) + if (aDims[0]->GetFunction() != sheet::GeneralFunction2::SUM) { cerr << "First data field should be SUM." << endl; return false; } - if (aDims[1]->GetFunction() != sheet::GeneralFunction_COUNT) + if (aDims[1]->GetFunction() != sheet::GeneralFunction2::COUNT) { cerr << "First data field should be COUNT." << endl; return false; @@ -2968,16 +2968,9 @@ void ScExportTest::testPivotTableMedian() std::vector::size_type(1), aDims.size()); const ScDPSaveDimension* pDim = aDims.back(); -#if 0 -// disabled because of css::sheet::GeneralFunction API incompatibility CPPUNIT_ASSERT_EQUAL_MESSAGE( "Function for the data field should be MEDIAN.", - sal_uInt16(sheet::GeneralFunction_MEDIAN), pDim->GetFunction()); -#else - CPPUNIT_ASSERT_EQUAL_MESSAGE( - "Function for the data field should be MEDIAN.", - sal_uInt16(sheet::GeneralFunction_NONE), pDim->GetFunction()); -#endif + sal_uInt16(sheet::GeneralFunction2::MEDIAN), pDim->GetFunction()); xDocSh2->DoClose(); } @@ -3669,7 +3662,6 @@ void ScExportTest::testHeaderImage() OUString aURL; xStyle->getPropertyValue("HeaderBackGraphicURL") >>= aURL; CPPUNIT_ASSERT(aURL.startsWith("vnd.sun.star.GraphicObject:")); - xDocSh->DoClose(); } diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index e2858a700b28..3b5efca85439 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -81,7 +81,7 @@ #include #include #include -#include +#include #include #include #include @@ -1876,7 +1876,7 @@ void ScFiltersTest::testPivotTableBasicODS() const ScDPSaveDimension* pDim = aDims.back(); CPPUNIT_ASSERT_EQUAL_MESSAGE( "Function for the data field should be COUNT.", - sal_uInt16(sheet::GeneralFunction_COUNT), pDim->GetFunction()); + sal_uInt16(sheet::GeneralFunction2::COUNT), pDim->GetFunction()); xDocSh->DoClose(); } diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx index 22d8744e0d23..ab220f18651d 100644 --- a/sc/source/core/data/dpobject.cxx +++ b/sc/source/core/data/dpobject.cxx @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include #include #include @@ -1335,7 +1335,7 @@ public: if (pLayoutName && ScGlobal::pCharClass->uppercase(*pLayoutName) == maName) return true; - sheet::GeneralFunction eGenFunc = static_cast(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& rFilters, - std::vector& rFilterFuncs, const OUString& rFilterList ) + std::vector& 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& x uno::Any aSubAny; try { - aSubAny = xLevProp->getPropertyValue( SC_UNO_DP_SUBTOTAL ); + aSubAny = xLevProp->getPropertyValue( SC_UNO_DP_SUBTOTAL2 ); } catch(uno::Exception&) { } - uno::Sequence aSeq; + uno::Sequence 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; iGetName()); pDim->SetOrientation(nOrient); diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx index 1bd6a62a5379..031aa129dca8 100644 --- a/sc/source/core/data/dpoutput.cxx +++ b/sc/source/core/data/dpoutput.cxx @@ -52,6 +52,7 @@ #include #include #include +#include #include @@ -1538,28 +1539,25 @@ bool ScDPOutput::GetDataResultPositionData(vector& 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 = ScUnoHelpFunctions::GetShortProperty( + 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 #include +#include #include #include #include @@ -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& 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(nFunction); + xDimProp->setPropertyValue( SC_UNO_DP_FUNCTION2, uno::Any(eFunc) ); if ( nUsedHierarchy >= 0 ) { @@ -629,11 +630,11 @@ void ScDPSaveDimension::WriteToSource( const uno::Reference& xD if ( !pSubTotalFuncs ) nSubTotalCount = 0; - uno::Sequence aSeq(nSubTotalCount); - sheet::GeneralFunction* pArray = aSeq.getArray(); + uno::Sequence aSeq(nSubTotalCount); + sal_Int16* pArray = aSeq.getArray(); for (long i=0; isetPropertyValue( SC_UNO_DP_SUBTOTAL, uno::Any(aSeq) ); + pArray[i] = static_cast(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 #include #include +#include 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 aSeq = pLevel->getSubTotals(); + uno::Sequence 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 aSeq = pParentLevel->getSubTotals(); + uno::Sequence 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 #include #include +#include #include #include @@ -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(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 SAL_CALL ScDPDimension::getPropertySetIn { OUString(SC_UNO_DP_FILTER), 0, cppu::UnoType>::get(), 0, 0 }, { OUString(SC_UNO_DP_FLAGS), 0, cppu::UnoType::get(), beans::PropertyAttribute::READONLY, 0 }, { OUString(SC_UNO_DP_FUNCTION), 0, cppu::UnoType::get(), 0, 0 }, + { OUString(SC_UNO_DP_FUNCTION2), 0, cppu::UnoType::get(), 0, 0 }, { OUString(SC_UNO_DP_ISDATALAYOUT), 0, cppu::UnoType::get(), beans::PropertyAttribute::READONLY, 0 }, { OUString(SC_UNO_DP_NUMBERFO), 0, cppu::UnoType::get(), beans::PropertyAttribute::READONLY, 0 }, { OUString(SC_UNO_DP_ORIENTATION), 0, cppu::UnoType::get(), 0, 0 }, @@ -1504,6 +1506,12 @@ void SAL_CALL ScDPDimension::setPropertyValue( const OUString& aPropertyName, co if (aValue >>= eEnum) setFunction( sal::static_int_cast(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(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 ScDPLevel::getSubTotals() const +uno::Sequence ScDPLevel::getSubTotals() const { //TODO: separate functions for settings and evaluation? long nSrcDim = pSource->GetSourceDim( nDim ); if ( !pSource->SubTotalAllowed( nSrcDim ) ) - return uno::Sequence(0); + return uno::Sequence(0); return aSubTotals; } @@ -2152,6 +2174,7 @@ uno::Reference SAL_CALL ScDPLevel::getPropertySetInfo() { OUString(SC_UNO_DP_REPEATITEMLABELS), 0, cppu::UnoType::get(), 0, 0 }, { OUString(SC_UNO_DP_SORTING), 0, cppu::UnoType::get(), 0, 0 }, { OUString(SC_UNO_DP_SUBTOTAL), 0, cppu::UnoType>::get(), 0, 0 }, + { OUString(SC_UNO_DP_SUBTOTAL2), 0, cppu::UnoType>::get(), 0, 0 }, { OUString(), 0, css::uno::Type(), 0, 0 } }; static uno::Reference 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 aSeq; + aValue >>= aSeq; + aSubTotals.realloc(aSeq.getLength()); + for (sal_Int32 nIndex = 0; nIndex < aSeq.getLength(); nIndex++) + { + aSubTotals[nIndex] = static_cast(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 aSeq = getSubTotals(); //TODO: avoid extra copy? + uno::Sequence aSeq = getSubTotals(); + uno::Sequence 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(aSeq[nIndex]); + } + + aRet <<= aNewSeq; + } + else if ( aPropertyName == SC_UNO_DP_SUBTOTAL2 ) + { + uno::Sequence 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 #include +#include 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 aFilterFuncs; + std::vector 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 +#include #include #include #include @@ -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 #include #include +#include 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(pDim->GetSubTotalFunc(nSubTotal)); + sal_Int16 nFunc = static_cast(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(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( - 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..41e3887201bb 100644 --- a/sc/source/ui/unoobj/dapiuno.cxx +++ b/sc/source/ui/unoobj/dapiuno.cxx @@ -50,6 +50,7 @@ #include #include #include +#include #include #include @@ -115,6 +116,7 @@ const SfxItemPropertyMapEntry* lcl_GetDataPilotFieldMap() { {OUString(SC_UNONAME_AUTOSHOW), 0, cppu::UnoType::get(), MAYBEVOID, 0 }, {OUString(SC_UNONAME_FUNCTION), 0, cppu::UnoType::get(), 0, 0 }, + {OUString(SC_UNONAME_FUNCTION2), 0, cppu::UnoType::get(), 0, 0 }, {OUString(SC_UNONAME_GROUPINFO), 0, cppu::UnoType::get(), MAYBEVOID, 0 }, {OUString(SC_UNONAME_HASAUTOSHOW), 0, cppu::UnoType::get(), 0, 0 }, {OUString(SC_UNONAME_HASLAYOUTINFO),0, cppu::UnoType::get(), 0, 0 }, @@ -129,6 +131,7 @@ const SfxItemPropertyMapEntry* lcl_GetDataPilotFieldMap() {OUString(SC_UNONAME_REPEATITEMLABELS), 0, cppu::UnoType::get(), 0, 0 }, {OUString(SC_UNONAME_SORTINFO), 0, cppu::UnoType::get(), MAYBEVOID, 0 }, {OUString(SC_UNONAME_SUBTOTALS), 0, cppu::UnoType>::get(), 0, 0 }, + {OUString(SC_UNONAME_SUBTOTALS2), 0, cppu::UnoType>::get(), 0, 0 }, {OUString(SC_UNONAME_USESELPAGE), 0, cppu::UnoType::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 (eFunction) ); + } + else if ( aPropertyName == SC_UNONAME_FUNCTION2 ) + { + sal_Int16 eFunction = ScUnoHelpFunctions::GetInt16FromAny( aValue ); setFunction( eFunction ); } else if ( aPropertyName == SC_UNONAME_SUBTOTALS ) { - Sequence< GeneralFunction > aSubtotals; + Sequence< sal_Int16 > aSubTotals; + uno::Sequence aSeq; + if( aValue >>= aSeq) + { + aSubTotals.realloc(aSeq.getLength()); + for (sal_Int32 nIndex = 0; nIndex < aSeq.getLength(); nIndex++) + { + aSubTotals[nIndex] = static_cast(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(nFunction); + } + aRet <<= eVal; + } + else if ( aPropertyName == SC_UNONAME_FUNCTION2 ) aRet <<= getFunction(); else if ( aPropertyName == SC_UNONAME_SUBTOTALS ) + { + uno::Sequence aSeq = getSubtotals(); + uno::Sequence 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(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(pDim->GetSubTotalFunc(0)); // always use the first one // else keep NONE } else - eRet = (GeneralFunction)pDim->GetFunction(); + eRet = static_cast(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(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; diff --git a/sc/source/ui/unoobj/miscuno.cxx b/sc/source/ui/unoobj/miscuno.cxx index fb870d5cdc8f..bb9a8ac68203 100644 --- a/sc/source/ui/unoobj/miscuno.cxx +++ b/sc/source/ui/unoobj/miscuno.cxx @@ -56,6 +56,24 @@ bool ScUnoHelpFunctions::GetBoolProperty( const uno::Reference& xProp, + const OUString& rName, sal_Int16 nDefault ) +{ + sal_Int16 nRet = nDefault; + if ( xProp.is() ) + { + try + { + xProp->getPropertyValue( rName ) >>= nRet; + } + catch(uno::Exception&) + { + // keep default + } + } + return nRet; +} + sal_Int32 ScUnoHelpFunctions::GetLongProperty( const uno::Reference& xProp, const OUString& rName ) { -- cgit