desktop/source/lib/init.cxx | 2 sc/inc/colorscale.hxx | 6 +- sc/sdi/scalc.sdi | 2 sc/source/core/data/colorscale.cxx | 4 - sc/source/ui/view/cellsh1.cxx | 92 ++++++++++++++++++++++++++----------- 5 files changed, 73 insertions(+), 33 deletions(-)
New commits: commit 9c20b03783ae07f40891422c1e8a943384b6f96d Author: Jan Holesovsky <ke...@collabora.com> AuthorDate: Mon Jun 25 22:58:30 2018 +0200 Commit: Miklos Vajna <vmik...@collabora.co.uk> CommitDate: Fri Oct 12 09:51:33 2018 +0200 Conditional formatting: Allow to set the icon set CF via .uno: command. When .uno:IconSetFormatDialog gets a parameter, it directly creates the icon set conditional formatting with pre-selected values. Change-Id: I75dda90e5ea9c191254acc24c564cda7b27243a5 Reviewed-on: https://gerrit.libreoffice.org/56429 Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> Tested-by: Miklos Vajna <vmik...@collabora.co.uk> Reviewed-on: https://gerrit.libreoffice.org/61660 diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 9d5f43108672..a7c2790150ee 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -322,6 +322,8 @@ std::vector<beans::PropertyValue> desktop::jsonToPropertyValuesVector(const char aValue.Value <<= OString(rValue.c_str()).toFloat(); else if (rType == "long") aValue.Value <<= OString(rValue.c_str()).toInt32(); + else if (rType == "short") + aValue.Value <<= static_cast<sal_Int16>(OString(rValue.c_str()).toInt32()); else if (rType == "unsigned short") aValue.Value <<= static_cast<sal_uInt16>(OString(rValue.c_str()).toUInt32()); else if (rType == "[]any") diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx index 19f00d7087e8..0adde0e30585 100644 --- a/sc/inc/colorscale.hxx +++ b/sc/inc/colorscale.hxx @@ -52,7 +52,7 @@ private: ScConditionalFormat* mpFormat; public: - ScColorScaleEntry(double nVal, const Color& rCol); + ScColorScaleEntry(double nVal, const Color& rCol, ScColorScaleEntryType eType = COLORSCALE_VALUE); ScColorScaleEntry(); ScColorScaleEntry(const ScColorScaleEntry& rEntry); ScColorScaleEntry(ScDocument* pDoc, const ScColorScaleEntry& rEntry); @@ -343,8 +343,8 @@ struct ScIconSetFormatData // std..pair::second == -1 means no image std::vector<std::pair<ScIconSetType, sal_Int32> > maCustomVector; - ScIconSetFormatData(): - eIconSetType(IconSet_3Arrows), + ScIconSetFormatData(ScIconSetType eType = IconSet_3Arrows): + eIconSetType(eType), mbShowValue(true), mbReverse(false), mbCustom(false) diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi index 3fc0f38cc92d..a1d176603e8b 100644 --- a/sc/sdi/scalc.sdi +++ b/sc/sdi/scalc.sdi @@ -739,7 +739,7 @@ SfxVoidItem DataBarFormatDialog SID_OPENDLG_DATABAR SfxVoidItem IconSetFormatDialog SID_OPENDLG_ICONSET -() +(SfxInt16Item IconSet FN_PARAM_1) [ AutoUpdate = FALSE, FastCall = FALSE, diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index df484f328c58..fedbb4230dc8 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -136,10 +136,10 @@ ScColorScaleEntry::ScColorScaleEntry(): { } -ScColorScaleEntry::ScColorScaleEntry(double nVal, const Color& rCol): +ScColorScaleEntry::ScColorScaleEntry(double nVal, const Color& rCol, ScColorScaleEntryType eType): mnVal(nVal), maColor(rCol), - meType(COLORSCALE_VALUE), + meType(eType), mpFormat(nullptr) { } diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx index 7a8710634b3b..622db89acb67 100644 --- a/sc/source/ui/view/cellsh1.cxx +++ b/sc/source/ui/view/cellsh1.cxx @@ -51,6 +51,7 @@ #include <svtools/cliplistener.hxx> #include <cellsh.hxx> +#include <ftools.hxx> #include <sc.hrc> #include <document.hxx> #include <patattr.hxx> @@ -80,6 +81,7 @@ #include <cliputil.hxx> #include <markdata.hxx> #include <docpool.hxx> +#include <colorscale.hxx> #include <condformatdlg.hxx> #include <attrib.hxx> #include <condformatdlgitem.hxx> @@ -101,6 +103,7 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <cppuhelper/bootstrap.hxx> +#include <o3tl/make_unique.hxx> #include <memory> using namespace ::com::sun::star; @@ -2007,15 +2010,16 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) aRangeList.push_back(pRange); } + // try to find an existing conditional format const ScConditionalFormat* pCondFormat = nullptr; const ScPatternAttr* pPattern = pDoc->GetPattern(aPos.Col(), aPos.Row(), aPos.Tab()); + ScConditionalFormatList* pList = pDoc->GetCondFormList(aPos.Tab()); const std::vector<sal_uInt32>& rCondFormats = pPattern->GetItem(ATTR_CONDITIONAL).GetCondFormatData(); bool bContainsCondFormat = !rCondFormats.empty(); bool bCondFormatDlg = false; + bool bContainsExistingCondFormat = false; if(bContainsCondFormat) { - bool bContainsExistingCondFormat = false; - ScConditionalFormatList* pList = pDoc->GetCondFormList(aPos.Tab()); for (std::vector<sal_uInt32>::const_iterator itr = rCondFormats.begin(), itrEnd = rCondFormats.end(); itr != itrEnd; ++itr) { @@ -2034,39 +2038,73 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) break; } } + } + + // do we have a parameter with the conditional formatting type? + const SfxInt16Item* pParam = rReq.GetArg<SfxInt16Item>(FN_PARAM_1); + if (pParam && nSlot == SID_OPENDLG_ICONSET) + { + ScConditionalFormat* pFormat = new ScConditionalFormat(0, pDoc); + pFormat->SetRange(aRangeList); + + ScIconSetType eIconSetType = limit_cast<ScIconSetType>(pParam->GetValue(), IconSet_3Arrows, IconSet_5Boxes); + int nSteps = 3; + if (eIconSetType >= IconSet_4Arrows && eIconSetType < IconSet_5Arrows) + nSteps = 4; + else if (eIconSetType >= IconSet_5Arrows) + nSteps = 5; + + ScIconSetFormat* pEntry = new ScIconSetFormat(pDoc); + ScIconSetFormatData* pIconSetFormatData = new ScIconSetFormatData(eIconSetType); + + pIconSetFormatData->m_Entries.push_back(o3tl::make_unique<ScColorScaleEntry>(0, COL_RED, COLORSCALE_PERCENT)); + pIconSetFormatData->m_Entries.push_back(o3tl::make_unique<ScColorScaleEntry>(round(100. / nSteps), COL_BROWN, COLORSCALE_PERCENT)); + pIconSetFormatData->m_Entries.push_back(o3tl::make_unique<ScColorScaleEntry>(round(200. / nSteps), COL_YELLOW, COLORSCALE_PERCENT)); + if (nSteps > 3) + pIconSetFormatData->m_Entries.push_back(o3tl::make_unique<ScColorScaleEntry>(round(300. / nSteps), COL_WHITE, COLORSCALE_PERCENT)); + if (nSteps > 4) + pIconSetFormatData->m_Entries.push_back(o3tl::make_unique<ScColorScaleEntry>(round(400. / nSteps), COL_GREEN, COLORSCALE_PERCENT)); - // if not found a conditional format ask whether we should edit one of the existing - // or should create a new overlapping conditional format - if(!bCondFormatDlg && bContainsExistingCondFormat) + pEntry->SetIconSetData(pIconSetFormatData); + pFormat->AddEntry(pEntry); + + // use the new conditional formatting + GetViewData()->GetDocShell()->GetDocFunc().ReplaceConditionalFormat(nIndex, pFormat, aPos.Tab(), aRangeList); + + break; + } + + // if not found a conditional format ask whether we should edit one of the existing + // or should create a new overlapping conditional format + if(bContainsCondFormat && !bCondFormatDlg && bContainsExistingCondFormat) + { + ScopedVclPtrInstance<QueryBox> aBox(pTabViewShell->GetDialogParent(), MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, + ScGlobal::GetRscString(STR_EDIT_EXISTING_COND_FORMATS)); + bool bEditExisting = aBox->Execute() == RET_YES; + if (bEditExisting) { - ScopedVclPtrInstance<QueryBox> aBox( pTabViewShell->GetDialogParent(), MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, - ScGlobal::GetRscString(STR_EDIT_EXISTING_COND_FORMATS) ); - bool bEditExisting = aBox->Execute() == RET_YES; - if(bEditExisting) + // differentiate between ranges where one conditional format is defined + // and several formats are defined + // if we have only one => open the cond format dlg to edit it + // otherwise open the manage cond format dlg + if (rCondFormats.size() == 1) { - // differentiate between ranges where one conditional format is defined - // and several formats are defined - // if we have only one => open the cond format dlg to edit it - // otherwise open the manage cond format dlg - if(rCondFormats.size() == 1) - { - pCondFormat = pList->GetFormat(rCondFormats[0]); - assert(pCondFormat); - bCondFormatDlg = true; - } - else - { - // Queue message to open Conditional Format Manager Dialog. - GetViewData()->GetDispatcher().Execute( SID_OPENDLG_CONDFRMT_MANAGER, SfxCallMode::ASYNCHRON ); - break; - } + pCondFormat = pList->GetFormat(rCondFormats[0]); + assert(pCondFormat); + bCondFormatDlg = true; } else { - // define an overlapping conditional format - // does not need to be handled here + // Queue message to open Conditional Format Manager Dialog. + GetViewData()->GetDispatcher().Execute( SID_OPENDLG_CONDFRMT_MANAGER, SfxCallMode::ASYNCHRON ); + break; } } + else + { + // define an overlapping conditional format + // does not need to be handled here + } } condformat::dialog::ScCondFormatDialogType eType = condformat::dialog::NONE; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits