summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@collabora.co.uk>2015-03-26 23:16:27 +0100
committerJan Holesovsky <kendy@collabora.com>2015-04-09 11:39:26 +0200
commit229b94472a714ca6c088138e304be33941275e2f (patch)
treebc02af9009b122b19a7fbaecaeb34ad06c3252c7
parentmore work for fixing lifecycle (diff)
downloadcore-229b94472a714ca6c088138e304be33941275e2f.tar.gz
core-229b94472a714ca6c088138e304be33941275e2f.zip
fix getPropertyValue/setPropertyValue for ScCondFormatEntry UNO object
Change-Id: Id1a3cc62288c6c618c8b86caaa69a96eb541d06f
-rw-r--r--sc/inc/conditio.hxx1
-rw-r--r--sc/source/core/data/conditio.cxx5
-rw-r--r--sc/source/ui/unoobj/condformatuno.cxx88
3 files changed, 86 insertions, 8 deletions
diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx
index 87cfcc30446d..ba2f91a4e411 100644
--- a/sc/inc/conditio.hxx
+++ b/sc/inc/conditio.hxx
@@ -199,6 +199,7 @@ public:
bool IsCellValid( ScRefCellValue& rCell, const ScAddress& rPos ) const;
ScConditionMode GetOperation() const { return eOp; }
+ void SetOperation(ScConditionMode eMode);
bool IsIgnoreBlank() const { return ( nOptions & SC_COND_NOBLANKS ) == 0; }
void SetIgnoreBlank(bool bSet);
ScAddress GetSrcPos() const { return aSrcPos; }
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index ab1adc06d1eb..6e4a10e2f055 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -322,6 +322,11 @@ ScConditionEntry::~ScConditionEntry()
delete pFormula2;
}
+void ScConditionEntry::SetOperation(ScConditionMode eMode)
+{
+ eOp = eMode;
+}
+
void ScConditionEntry::Compile( const OUString& rExpr1, const OUString& rExpr2,
const OUString& rExprNmsp1, const OUString& rExprNmsp2,
FormulaGrammar::Grammar eGrammar1, FormulaGrammar::Grammar eGrammar2, bool bTextToReal )
diff --git a/sc/source/ui/unoobj/condformatuno.cxx b/sc/source/ui/unoobj/condformatuno.cxx
index 81e32f7a2449..9aad8552a66f 100644
--- a/sc/source/ui/unoobj/condformatuno.cxx
+++ b/sc/source/ui/unoobj/condformatuno.cxx
@@ -14,6 +14,8 @@
#include "colorscale.hxx"
#include "docsh.hxx"
#include "miscuno.hxx"
+#include "compiler.hxx"
+#include "tokenarray.hxx"
#include "cellsuno.hxx"
#include "convuno.hxx"
@@ -72,11 +74,35 @@ struct ConditionEntryApiMap
sal_Int32 nApiMode;
};
-/*
ConditionEntryApiMap aConditionEntryMap[] =
{
+ {SC_COND_EQUAL, sheet::ConditionFormatOperator::EQUAL},
+ {SC_COND_LESS, sheet::ConditionFormatOperator::LESS},
+ {SC_COND_GREATER, sheet::ConditionFormatOperator::GREATER},
+ {SC_COND_EQLESS, sheet::ConditionFormatOperator::LESS_EQUAL},
+ {SC_COND_EQGREATER, sheet::ConditionFormatOperator::GREATER_EQUAL},
+ {SC_COND_NOTEQUAL, sheet::ConditionFormatOperator::NOT_EQUAL},
+ {SC_COND_BETWEEN, sheet::ConditionFormatOperator::BETWEEN},
+ {SC_COND_NOTBETWEEN, sheet::ConditionFormatOperator::NOT_BETWEEN},
+ {SC_COND_DUPLICATE, sheet::ConditionFormatOperator::DUPLICATE},
+ {SC_COND_NOTDUPLICATE, sheet::ConditionFormatOperator::UNIQUE},
+ {SC_COND_DIRECT, sheet::ConditionFormatOperator::EXPRESSION},
+ {SC_COND_TOP10, sheet::ConditionFormatOperator::TOP_N_ELEMENTS},
+ {SC_COND_BOTTOM10, sheet::ConditionFormatOperator::BOTTOM_N_ELEMENTS},
+ {SC_COND_TOP_PERCENT, sheet::ConditionFormatOperator::TOP_N_PERCENT},
+ {SC_COND_BOTTOM_PERCENT, sheet::ConditionFormatOperator::BOTTOM_N_PERCENT},
+ {SC_COND_ABOVE_AVERAGE, sheet::ConditionFormatOperator::ABOVE_AVERAGE},
+ {SC_COND_BELOW_AVERAGE, sheet::ConditionFormatOperator::BELOW_AVERAGE},
+ {SC_COND_ABOVE_EQUAL_AVERAGE, sheet::ConditionFormatOperator::ABOVE_EQUAL_AVERAGE},
+ {SC_COND_BELOW_EQUAL_AVERAGE, sheet::ConditionFormatOperator::BELOW_EQUAL_AVERAGE},
+ {SC_COND_ERROR, sheet::ConditionFormatOperator::ERROR},
+ {SC_COND_NOERROR, sheet::ConditionFormatOperator::NO_ERROR},
+ {SC_COND_BEGINS_WITH, sheet::ConditionFormatOperator::BEGINS_WITH},
+ {SC_COND_ENDS_WITH, sheet::ConditionFormatOperator::ENDS_WITH},
+ {SC_COND_CONTAINS_TEXT, sheet::ConditionFormatOperator::CONTAINS},
+ {SC_COND_NOT_CONTAINS_TEXT, sheet::ConditionFormatOperator::NOT_CONTAINS},
+ {SC_COND_NONE, sheet::ConditionFormatOperator::EQUAL},
};
-*/
enum ColorScaleProperties
{
@@ -475,7 +501,7 @@ uno::Reference<beans::XPropertySetInfo> SAL_CALL ScConditionEntryObj::getPropert
}
void SAL_CALL ScConditionEntryObj::setPropertyValue(
- const OUString& aPropertyName, const uno::Any& /*aValue*/ )
+ const OUString& aPropertyName, const uno::Any& aValue )
throw(beans::UnknownPropertyException, beans::PropertyVetoException,
lang::IllegalArgumentException, lang::WrappedTargetException,
uno::RuntimeException, std::exception)
@@ -490,12 +516,49 @@ void SAL_CALL ScConditionEntryObj::setPropertyValue(
switch(pEntry->nWID)
{
case StyleName:
+ {
+ OUString aStyleName;
+ if ((aValue >>= aStyleName) && !aStyleName.isEmpty())
+ getCoreObject()->UpdateStyleName(aStyleName);
+ }
break;
case Formula1:
+ {
+ OUString aFormula;
+ if ((aValue >>= aFormula) && !aFormula.isEmpty())
+ {
+ ScCompiler aComp(&mpDocShell->GetDocument(), getCoreObject()->GetSrcPos());
+ boost::scoped_ptr<ScTokenArray> pArr(aComp.CompileString(aFormula));
+ getCoreObject()->SetFormula1(*pArr);
+ }
+ }
break;
case Formula2:
+ {
+ OUString aFormula;
+ if ((aValue >>= aFormula) && !aFormula.isEmpty())
+ {
+ ScCompiler aComp(&mpDocShell->GetDocument(), getCoreObject()->GetSrcPos());
+ boost::scoped_ptr<ScTokenArray> pArr(aComp.CompileString(aFormula));
+ getCoreObject()->SetFormula2(*pArr);
+ }
+ }
break;
case Operator:
+ {
+ sal_Int32 nVal;
+ if (aValue >>= nVal)
+ {
+ for (size_t i = 0; i < SAL_N_ELEMENTS(aConditionEntryMap); ++i)
+ {
+ if (aConditionEntryMap[i].nApiMode == nVal)
+ {
+ getCoreObject()->SetOperation(aConditionEntryMap[i].eMode);
+ break;
+ }
+ }
+ }
+ }
break;
default:
SAL_WARN("sc", "unsupported property");
@@ -517,25 +580,34 @@ uno::Any SAL_CALL ScConditionEntryObj::getPropertyValue( const OUString& aProper
switch(pEntry->nWID)
{
case StyleName:
- aAny <<= pFormat->GetStyle();
+ aAny <<= getCoreObject()->GetStyle();
break;
case Formula1:
{
- ScAddress aCursor = pFormat->GetSrcPos();
- OUString aFormula = pFormat->GetExpression(aCursor, 0);
+ ScAddress aCursor = getCoreObject()->GetSrcPos();
+ OUString aFormula = getCoreObject()->GetExpression(aCursor, 0);
aAny <<= aFormula;
}
break;
case Formula2:
{
- ScAddress aCursor = pFormat->GetSrcPos();
- OUString aFormula = pFormat->GetExpression(aCursor, 1);
+ ScAddress aCursor = getCoreObject()->GetSrcPos();
+ OUString aFormula = getCoreObject()->GetExpression(aCursor, 1);
aAny <<= aFormula;
}
break;
case Operator:
{
+ ScConditionMode eMode = getCoreObject()->GetOperation();
+ for (size_t i = 0; i < SAL_N_ELEMENTS(aConditionEntryMap); ++i)
+ {
+ if (aConditionEntryMap[i].eMode == eMode)
+ {
+ aAny <<= aConditionEntryMap[i].nApiMode;
+ break;
+ }
+ }
}
break;
default: