summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Carl <j.carl43@gmx.de>2018-01-23 01:45:21 +0000
committerJens Carl <j.carl43@gmx.de>2018-01-23 19:04:52 +0100
commitcceaece18a42405190941865908636522e0ee4cb (patch)
treec5b1d7a4755b6b259f0f55177a888bc055781df4
parent659109609ba2a7a827a4920c9456432b70cb001a (diff)
offapi: Add properties FormulaResultType2 and CellContentType
Add two new properties to SheetCell.idl "FormulaResultType2" and "CellContentType", because the "FormulaResultType" is returning the wrong value (com::sun::star::table::CellContentType instead of com::sun::star::sheet::FormulaResult). Also documeted the curiosity. Change-Id: Icc6538e155ba27fb9d097d8790ac9b4b230c1446 Reviewed-on: https://gerrit.libreoffice.org/48367 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Jens Carl <j.carl43@gmx.de>
-rw-r--r--offapi/com/sun/star/sheet/SheetCell.idl23
-rw-r--r--sc/inc/cellsuno.hxx3
-rw-r--r--sc/inc/unonames.hxx2
-rw-r--r--sc/inc/unowids.hxx4
-rw-r--r--sc/source/ui/unoobj/cellsuno.cxx48
5 files changed, 72 insertions, 8 deletions
diff --git a/offapi/com/sun/star/sheet/SheetCell.idl b/offapi/com/sun/star/sheet/SheetCell.idl
index 77411c4b68f2..8d85585d0c74 100644
--- a/offapi/com/sun/star/sheet/SheetCell.idl
+++ b/offapi/com/sun/star/sheet/SheetCell.idl
@@ -43,6 +43,7 @@
#include <com/sun/star/awt/Point.idl>
#include <com/sun/star/awt/Size.idl>
+#include <com/sun/star/table/CellContentType.idl>
#include <com/sun/star/sheet/XSheetConditionalEntries.idl>
#include <com/sun/star/beans/XPropertySet.idl>
#include <com/sun/star/beans/XTolerantMultiPropertySet.idl>
@@ -179,9 +180,11 @@ published service SheetCell
[optional, property] string FormulaLocal;
- /** contains the result type of a formula.
+ /** contains the content type of the cell.
- @see com::sun::star::sheet::FormulaResult
+ <p>This property returns not com::sun::star::sheet::FormulaResult
+ but instead com::sun::star::table::CellContentType. Use FormulaResult2
+ if the correct property is needed.</p>
*/
[readonly, property] long FormulaResultType;
@@ -233,6 +236,22 @@ published service SheetCell
/** Returns the absolute address of the range as string, e.g. "$Sheet1.$B$2".
*/
[optional, readonly, property] string AbsoluteName;
+
+
+ /** contains the content type of the cell.
+
+ @see com::sun::star::table::CellContentType
+ @since LibreOffice 6.1
+ */
+ [optional, readonly, property] com::sun::star::table::CellContentType CellContentType;
+
+
+ /** contains the result type of a formula.
+
+ @see com::sun::star::sheet::FormulaResult
+ @since LibreOffice 6.1
+ */
+ [optional, readonly, property] long FormulaResultType2;
};
diff --git a/sc/inc/cellsuno.hxx b/sc/inc/cellsuno.hxx
index b654141dcab5..8e0a80668dec 100644
--- a/sc/inc/cellsuno.hxx
+++ b/sc/inc/cellsuno.hxx
@@ -653,7 +653,8 @@ private:
void SetString_Impl(const OUString& rString, bool bInterpret, bool bEnglish);
double GetValue_Impl() const;
void SetValue_Impl(double fValue);
- css::table::CellContentType GetResultType_Impl();
+ css::table::CellContentType GetContentType_Impl();
+ sal_Int32 GetResultType_Impl();
protected:
virtual const SfxItemPropertyMap& GetItemPropertyMap() override;
diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx
index f8bf85968615..0f61dcd2a7d4 100644
--- a/sc/inc/unonames.hxx
+++ b/sc/inc/unonames.hxx
@@ -209,6 +209,8 @@
#define SC_UNONAME_VALIXML "ValidationXML"
#define SC_UNONAME_FORMLOC "FormulaLocal"
#define SC_UNONAME_FORMRT "FormulaResultType"
+#define SC_UNONAME_FORMRT2 "FormulaResultType2"
+#define SC_UNONAME_CELLCONTENTTYPE "CellContentType"
#define SC_UNONAME_USERDEF "UserDefinedAttributes"
#define SC_UNONAME_TEXTUSER "TextUserDefinedAttributes"
diff --git a/sc/inc/unowids.hxx b/sc/inc/unowids.hxx
index e099dd2c27fb..492972941c63 100644
--- a/sc/inc/unowids.hxx
+++ b/sc/inc/unowids.hxx
@@ -73,7 +73,9 @@
#define SC_WID_UNO_TBLBORD2 ( SC_WID_UNO_START + 43 )
#define SC_WID_UNO_CONDFORMAT ( SC_WID_UNO_START + 44 )
#define SC_WID_UNO_FORMATID ( SC_WID_UNO_START + 45 )
-#define SC_WID_UNO_END ( SC_WID_UNO_START + 45 )
+#define SC_WID_UNO_FORMRT2 ( SC_WID_UNO_START + 46 )
+#define SC_WID_UNO_CELLCONTENTTYPE ( SC_WID_UNO_START + 47 )
+#define SC_WID_UNO_END ( SC_WID_UNO_START + 47 )
inline bool IsScUnoWid( sal_uInt16 nWid )
{
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 2ee12640cd04..2731e69cfc79 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -442,6 +442,8 @@ static const SfxItemPropertySet* lcl_GetCellPropertySet()
{OUString(SC_UNONAME_DIAGONAL_TLBR2), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
{OUString(SC_UNONAME_FORMLOC), SC_WID_UNO_FORMLOC, cppu::UnoType<OUString>::get(), 0, 0 },
{OUString(SC_UNONAME_FORMRT), SC_WID_UNO_FORMRT, cppu::UnoType<table::CellContentType>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
+ {OUString(SC_UNONAME_CELLCONTENTTYPE), SC_WID_UNO_CELLCONTENTTYPE, cppu::UnoType<table::CellContentType>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
+ {OUString(SC_UNONAME_FORMRT2), SC_WID_UNO_FORMRT2, cppu::UnoType<sal_Int32>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
{OUString(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, cppu::UnoType<table::CellHoriJustify>::get(), 0, MID_HORJUST_HORJUST },
{OUString(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
{OUString(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, cppu::UnoType<bool>::get(), 0, MID_GRAPHIC_TRANSPARENT },
@@ -6406,7 +6408,39 @@ table::CellContentType SAL_CALL ScCellObj::getType()
return eRet;
}
-table::CellContentType ScCellObj::GetResultType_Impl()
+sal_Int32 ScCellObj::GetResultType_Impl()
+{
+ SolarMutexGuard aGuard;
+ sal_Int32 eRet = sheet::FormulaResult::STRING;
+ ScDocShell* pDocSh = GetDocShell();
+ if (pDocSh)
+ {
+ if (pDocSh->GetDocument().GetCellType(aCellPos) == CELLTYPE_FORMULA)
+ {
+ ScFormulaCell* pFCell = pDocSh->GetDocument().GetFormulaCell(aCellPos);
+ if (pFCell->GetErrCode() != FormulaError::NONE )
+ {
+ eRet = sheet::FormulaResult::ERROR;
+ }
+ else if (pFCell->IsValue())
+ {
+ eRet = sheet::FormulaResult::VALUE;
+ }
+ else
+ {
+ eRet = sheet::FormulaResult::STRING;
+ }
+ }
+ }
+ else
+ {
+ OSL_FAIL("no DocShell");
+ }
+
+ return eRet;
+}
+
+table::CellContentType ScCellObj::GetContentType_Impl()
{
ScDocShell* pDocSh = GetDocShell();
if ( pDocSh )
@@ -6542,7 +6576,8 @@ void ScCellObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, c
OUString aString(aStrVal);
SetString_Impl(aString, true, false); // interpret locally
}
- else if ( pEntry->nWID == SC_WID_UNO_FORMRT )
+ else if ( pEntry->nWID == SC_WID_UNO_FORMRT || pEntry->nWID == SC_WID_UNO_FORMRT2
+ || pEntry->nWID == SC_WID_UNO_CELLCONTENTTYPE )
{
// Read-Only
//! Exception or so...
@@ -6561,9 +6596,14 @@ void ScCellObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, u
// sal_False = local
rAny <<= GetInputString_Impl(false);
}
- else if ( pEntry->nWID == SC_WID_UNO_FORMRT )
+ else if ( pEntry->nWID == SC_WID_UNO_FORMRT2 )
+ {
+ sal_Int32 eType = GetResultType_Impl();
+ rAny <<= eType;
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_CELLCONTENTTYPE || pEntry->nWID == SC_WID_UNO_FORMRT )
{
- table::CellContentType eType = GetResultType_Impl();
+ table::CellContentType eType = GetContentType_Impl();
rAny <<= eType;
}
else