summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2015-04-03 16:44:51 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2015-04-03 17:44:23 +0200
commit5b75b4e1ec77515db811be9d7895bb7bd9d23088 (patch)
tree870f5ca9e88c0bca45a5ef372ab0be765c2f5152
parenteedf546acb878cb7c5856d33aad7496c1ad23269 (diff)
first part for correct handling of new cond format entries
Change-Id: I82f66218bf02898e523e4f69fec9166aa00d0b83
-rw-r--r--offapi/com/sun/star/sheet/XConditionalFormat.idl11
-rw-r--r--sc/inc/colorscale.hxx18
-rw-r--r--sc/source/core/data/colorscale.cxx85
-rw-r--r--sc/source/ui/inc/condformatuno.hxx5
-rw-r--r--sc/source/ui/unoobj/condformatuno.cxx36
5 files changed, 126 insertions, 29 deletions
diff --git a/offapi/com/sun/star/sheet/XConditionalFormat.idl b/offapi/com/sun/star/sheet/XConditionalFormat.idl
index 62f99621f5de..aed1fec7ecdc 100644
--- a/offapi/com/sun/star/sheet/XConditionalFormat.idl
+++ b/offapi/com/sun/star/sheet/XConditionalFormat.idl
@@ -17,7 +17,16 @@ module com { module sun { module star { module sheet {
interface XConditionalFormat : com::sun::star::container::XIndexAccess
{
- void addEntry( [in] com::sun::star::sheet::XConditionEntry entry );
+ /**
+ * Creates a new conditional format entry and insert its at the position.
+ *
+ * @param Type: a com.sun.star.sheet.ConditionFormatEntryType specifying the
+ * type of the new entry
+ *
+ * @param Position: the position in the conditional format
+ *
+ */
+ void createEntry( [in] long Type, [in] long Position );
void removeByIndex( [in] long Index );
};
diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx
index 74097062ed9b..110a27a7c42c 100644
--- a/sc/inc/colorscale.hxx
+++ b/sc/inc/colorscale.hxx
@@ -284,6 +284,12 @@ public:
ScColorScaleEntry* GetEntry(size_t nPos);
size_t size() const;
+
+ /**
+ * Makes sure that the maColorScales contain at least 2 entries.
+ * Should be called when it is not sure that the format is valid.
+ */
+ void EnsureSize();
};
class SC_DLLPUBLIC ScDataBarFormat : public ScColorFormat
@@ -309,6 +315,12 @@ public:
virtual condformat::ScFormatEntryType GetType() const SAL_OVERRIDE;
+ /**
+ * Makes sure that the mpFormatData does not contain valid entries.
+ * Should be called when it is not sure that the format is valid.
+ */
+ void EnsureSize();
+
private:
double getMin(double nMin, double nMax) const;
double getMax(double nMin, double nMax) const;
@@ -370,6 +382,12 @@ public:
size_t size() const;
+ /**
+ * Makes sure that the mpFormatData does not contain valid entries.
+ * Should be called when it is not sure that the format is valid.
+ */
+ void EnsureSize();
+
private:
double GetMinValue() const;
diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx
index 9f02077e23bc..ed1956fcb48c 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -684,6 +684,14 @@ size_t ScColorScaleFormat::size() const
return maColorScales.size();
}
+void ScColorScaleFormat::EnsureSize()
+{
+ if (maColorScales.size() < 2)
+ {
+ // TODO: create 2 valid entries
+ }
+}
+
ScDataBarFormat::ScDataBarFormat(ScDocument* pDoc):
ScColorFormat(pDoc)
{
@@ -944,6 +952,18 @@ ScDataBarInfo* ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const
return pInfo;
}
+void ScDataBarFormat::EnsureSize()
+{
+ if (!mpFormatData->mpLowerLimit)
+ {
+ // TODO: implement
+ }
+ if (!mpFormatData->mpUpperLimit)
+ {
+ // TODO: implement
+ }
+}
+
ScIconSetFormat::ScIconSetFormat(ScDocument* pDoc):
ScColorFormat(pDoc),
mpFormatData(new ScIconSetFormatData)
@@ -1156,32 +1176,35 @@ double ScIconSetFormat::CalcValue(double nMin, double nMax, ScIconSetFormat::con
return itr->GetValue();
}
-ScIconSetMap* ScIconSetFormat::getIconSetMap()
-{
+namespace {
+
+ScIconSetMap aIconSetMap[] = {
+ { "3Arrows", IconSet_3Arrows, 3 },
+ { "3ArrowsGray", IconSet_3ArrowsGray, 3 },
+ { "3Flags", IconSet_3Flags, 3 },
+ { "3TrafficLights1", IconSet_3TrafficLights1, 3 },
+ { "3TrafficLights2", IconSet_3TrafficLights2, 3 },
+ { "3Signs", IconSet_3Signs, 3 },
+ { "3Symbols", IconSet_3Symbols, 3 },
+ { "3Symbols2", IconSet_3Symbols2, 3 },
+ { "3Smilies", IconSet_3Smilies, 3 },
+ { "3ColorSmilies", IconSet_3ColorSmilies, 3 },
+ { "4Arrows", IconSet_4Arrows, 4 },
+ { "4ArrowsGray", IconSet_4ArrowsGray, 4 },
+ { "4RedToBlack", IconSet_4RedToBlack, 4 },
+ { "4Rating", IconSet_4Rating, 4 },
+ { "4TrafficLights", IconSet_4TrafficLights, 4 },
+ { "5Arrows", IconSet_5Arrows, 5 },
+ { "5ArrowsGray", IconSet_5ArrowsGray, 5 },
+ { "5Rating", IconSet_5Ratings, 5 },
+ { "5Quarters", IconSet_5Quarters, 5 },
+ { NULL, IconSet_3Arrows, 0 }
+};
- static ScIconSetMap aIconSetMap[] = {
- { "3Arrows", IconSet_3Arrows, 3 },
- { "3ArrowsGray", IconSet_3ArrowsGray, 3 },
- { "3Flags", IconSet_3Flags, 3 },
- { "3TrafficLights1", IconSet_3TrafficLights1, 3 },
- { "3TrafficLights2", IconSet_3TrafficLights2, 3 },
- { "3Signs", IconSet_3Signs, 3 },
- { "3Symbols", IconSet_3Symbols, 3 },
- { "3Symbols2", IconSet_3Symbols2, 3 },
- { "3Smilies", IconSet_3Smilies, 3 },
- { "3ColorSmilies", IconSet_3ColorSmilies, 3 },
- { "4Arrows", IconSet_4Arrows, 4 },
- { "4ArrowsGray", IconSet_4ArrowsGray, 4 },
- { "4RedToBlack", IconSet_4RedToBlack, 4 },
- { "4Rating", IconSet_4Rating, 4 },
- { "4TrafficLights", IconSet_4TrafficLights, 4 },
- { "5Arrows", IconSet_5Arrows, 5 },
- { "5ArrowsGray", IconSet_5ArrowsGray, 5 },
- { "5Rating", IconSet_5Ratings, 5 },
- { "5Quarters", IconSet_5Quarters, 5 },
- { NULL, IconSet_3Arrows, 0 }
- };
+}
+ScIconSetMap* ScIconSetFormat::getIconSetMap()
+{
return aIconSetMap;
}
@@ -1329,4 +1352,18 @@ BitmapEx& ScIconSetFormat::getBitmap( ScIconSetType eType, sal_Int32 nIndex )
return itrNew.first->second;
}
+void ScIconSetFormat::EnsureSize()
+{
+ ScIconSetType eType = mpFormatData->eIconSetType;
+ for (size_t i = 0; i < SAL_N_ELEMENTS(aIconSetMap); ++i)
+ {
+ if (aIconSetMap[i].eType == eType)
+ {
+ size_t nElements = aIconSetMap[i].nElements;
+ // TODO: implement
+ break;
+ }
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/condformatuno.hxx b/sc/source/ui/inc/condformatuno.hxx
index b5839e4e41ea..0e70a853616f 100644
--- a/sc/source/ui/inc/condformatuno.hxx
+++ b/sc/source/ui/inc/condformatuno.hxx
@@ -96,9 +96,8 @@ public:
ScDocShell* getDocShell();
// XConditionalFormat
- virtual void SAL_CALL addEntry(const uno::Reference<sheet::XConditionEntry>& xEntry)
- throw(::com::sun::star::uno::RuntimeException,
- std::exception) SAL_OVERRIDE;
+ virtual void SAL_CALL createEntry(const sal_Int32 nType, const sal_Int32 nPos)
+ throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual void SAL_CALL removeByIndex(const sal_Int32 nIndex)
throw(::com::sun::star::uno::RuntimeException,
diff --git a/sc/source/ui/unoobj/condformatuno.cxx b/sc/source/ui/unoobj/condformatuno.cxx
index 8efdc9475514..0acab072c91c 100644
--- a/sc/source/ui/unoobj/condformatuno.cxx
+++ b/sc/source/ui/unoobj/condformatuno.cxx
@@ -470,9 +470,43 @@ ScDocShell* ScCondFormatObj::getDocShell()
return mpDocShell;
}
-void ScCondFormatObj::addEntry(const uno::Reference<sheet::XConditionEntry>& /*xEntry*/)
+void ScCondFormatObj::createEntry(const sal_Int32 nType, const sal_Int32 nPos)
throw(uno::RuntimeException, std::exception)
{
+ SolarMutexGuard aGuard;
+ ScConditionalFormat* pFormat = getCoreObject();
+ if (nPos > sal_Int32(pFormat->size()))
+ throw lang::IllegalArgumentException();
+
+ ScFormatEntry* pNewEntry = NULL;
+ ScDocument* pDoc = &mpDocShell->GetDocument();
+ switch (nType)
+ {
+ case sheet::ConditionEntryType::CONDITION:
+ pNewEntry = new ScCondFormatEntry(SC_COND_EQUAL, "", "",
+ pDoc, pFormat->GetRange().GetTopLeftCorner(), "");
+ break;
+ case sheet::ConditionEntryType::COLORSCALE:
+ pNewEntry = new ScColorScaleFormat(pDoc);
+ static_cast<ScColorScaleFormat*>(pNewEntry)->EnsureSize();
+ break;
+ case sheet::ConditionEntryType::DATABAR:
+ pNewEntry = new ScDataBarFormat(pDoc);
+ static_cast<ScDataBarFormat*>(pNewEntry)->EnsureSize();
+ break;
+ case sheet::ConditionEntryType::ICONSET:
+ pNewEntry = new ScIconSetFormat(pDoc);
+ static_cast<ScIconSetFormat*>(pNewEntry)->EnsureSize();
+ break;
+ case sheet::ConditionEntryType::DATE:
+ pNewEntry = new ScCondDateFormatEntry(pDoc);
+ break;
+ default:
+ SAL_WARN("sc", "unknown conditional format type");
+ throw lang::IllegalArgumentException();
+ }
+
+ pFormat->AddEntry(pNewEntry);
}
void ScCondFormatObj::removeByIndex(const sal_Int32 nIndex)