Kaydet (Commit) cceaece1 authored tarafından Jens Carl's avatar Jens Carl

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/48367Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarJens Carl <j.carl43@gmx.de>
üst 65910960
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include <com/sun/star/awt/Point.idl> #include <com/sun/star/awt/Point.idl>
#include <com/sun/star/awt/Size.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/sheet/XSheetConditionalEntries.idl>
#include <com/sun/star/beans/XPropertySet.idl> #include <com/sun/star/beans/XPropertySet.idl>
#include <com/sun/star/beans/XTolerantMultiPropertySet.idl> #include <com/sun/star/beans/XTolerantMultiPropertySet.idl>
...@@ -179,9 +180,11 @@ published service SheetCell ...@@ -179,9 +180,11 @@ published service SheetCell
[optional, property] string FormulaLocal; [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; [readonly, property] long FormulaResultType;
...@@ -233,6 +236,22 @@ published service SheetCell ...@@ -233,6 +236,22 @@ published service SheetCell
/** Returns the absolute address of the range as string, e.g. "$Sheet1.$B$2". /** Returns the absolute address of the range as string, e.g. "$Sheet1.$B$2".
*/ */
[optional, readonly, property] string AbsoluteName; [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;
}; };
......
...@@ -653,7 +653,8 @@ private: ...@@ -653,7 +653,8 @@ private:
void SetString_Impl(const OUString& rString, bool bInterpret, bool bEnglish); void SetString_Impl(const OUString& rString, bool bInterpret, bool bEnglish);
double GetValue_Impl() const; double GetValue_Impl() const;
void SetValue_Impl(double fValue); void SetValue_Impl(double fValue);
css::table::CellContentType GetResultType_Impl(); css::table::CellContentType GetContentType_Impl();
sal_Int32 GetResultType_Impl();
protected: protected:
virtual const SfxItemPropertyMap& GetItemPropertyMap() override; virtual const SfxItemPropertyMap& GetItemPropertyMap() override;
......
...@@ -209,6 +209,8 @@ ...@@ -209,6 +209,8 @@
#define SC_UNONAME_VALIXML "ValidationXML" #define SC_UNONAME_VALIXML "ValidationXML"
#define SC_UNONAME_FORMLOC "FormulaLocal" #define SC_UNONAME_FORMLOC "FormulaLocal"
#define SC_UNONAME_FORMRT "FormulaResultType" #define SC_UNONAME_FORMRT "FormulaResultType"
#define SC_UNONAME_FORMRT2 "FormulaResultType2"
#define SC_UNONAME_CELLCONTENTTYPE "CellContentType"
#define SC_UNONAME_USERDEF "UserDefinedAttributes" #define SC_UNONAME_USERDEF "UserDefinedAttributes"
#define SC_UNONAME_TEXTUSER "TextUserDefinedAttributes" #define SC_UNONAME_TEXTUSER "TextUserDefinedAttributes"
......
...@@ -73,7 +73,9 @@ ...@@ -73,7 +73,9 @@
#define SC_WID_UNO_TBLBORD2 ( SC_WID_UNO_START + 43 ) #define SC_WID_UNO_TBLBORD2 ( SC_WID_UNO_START + 43 )
#define SC_WID_UNO_CONDFORMAT ( SC_WID_UNO_START + 44 ) #define SC_WID_UNO_CONDFORMAT ( SC_WID_UNO_START + 44 )
#define SC_WID_UNO_FORMATID ( SC_WID_UNO_START + 45 ) #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 ) inline bool IsScUnoWid( sal_uInt16 nWid )
{ {
......
...@@ -442,6 +442,8 @@ static const SfxItemPropertySet* lcl_GetCellPropertySet() ...@@ -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_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_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_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), 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_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 }, {OUString(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, cppu::UnoType<bool>::get(), 0, MID_GRAPHIC_TRANSPARENT },
...@@ -6406,7 +6408,39 @@ table::CellContentType SAL_CALL ScCellObj::getType() ...@@ -6406,7 +6408,39 @@ table::CellContentType SAL_CALL ScCellObj::getType()
return eRet; 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(); ScDocShell* pDocSh = GetDocShell();
if ( pDocSh ) if ( pDocSh )
...@@ -6542,7 +6576,8 @@ void ScCellObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, c ...@@ -6542,7 +6576,8 @@ void ScCellObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, c
OUString aString(aStrVal); OUString aString(aStrVal);
SetString_Impl(aString, true, false); // interpret locally 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 // Read-Only
//! Exception or so... //! Exception or so...
...@@ -6561,9 +6596,14 @@ void ScCellObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, u ...@@ -6561,9 +6596,14 @@ void ScCellObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, u
// sal_False = local // sal_False = local
rAny <<= GetInputString_Impl(false); 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; rAny <<= eType;
} }
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment