summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-12-14 10:03:05 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-12-15 07:51:29 +0100
commit7073310431becb1a69af0c7187b9844ce7901cd5 (patch)
tree76e958c137da93600c9a8e94beaa65a83c4ed152 /sc
parent696644dbfb25dea3030da92b2ab40cd70da90f05 (diff)
make editing conditional formats more obvious, related fdo#57895
Change-Id: I2ea95a204fbbd0d36a8fb1374e41aa5aae3cf410
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/globstr.hrc11
-rw-r--r--sc/source/ui/src/globstr.src4
-rw-r--r--sc/source/ui/view/cellsh1.cxx71
3 files changed, 73 insertions, 13 deletions
diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index c1873b5bfb52..e860a6b68704 100644
--- a/sc/inc/globstr.hrc
+++ b/sc/inc/globstr.hrc
@@ -615,12 +615,13 @@
#define STR_COND_DATE 490
#define STR_ERR_CONDFORMAT_PROTECTED 491
+#define STR_EDIT_EXISTING_COND_FORMATS 492
-#define STR_QUERY_FORMULA_RECALC_ONLOAD_ODS 492
-#define STR_QUERY_FORMULA_RECALC_ONLOAD_XLS 493
-#define STR_ALWAYS 494
-#define STR_NEVER 495
+#define STR_QUERY_FORMULA_RECALC_ONLOAD_ODS 493
+#define STR_QUERY_FORMULA_RECALC_ONLOAD_XLS 494
+#define STR_ALWAYS 495
+#define STR_NEVER 496
-#define STR_COUNT 496
+#define STR_COUNT 497
#endif
diff --git a/sc/source/ui/src/globstr.src b/sc/source/ui/src/globstr.src
index 88cb11ce14f3..955dcb5f12fc 100644
--- a/sc/source/ui/src/globstr.src
+++ b/sc/source/ui/src/globstr.src
@@ -1946,6 +1946,10 @@ Resource RID_GLOBSTR
{
Text [ en-US ] = "Conditional Formats can not be created, deleted or changed in protected sheets!";
};
+ String STR_EDIT_EXISTING_COND_FORMATS
+ {
+ Text [ en-US ] = "The selected cell already contains conditional formatting. You can either edit the existing conditional format or you define a new overlapping conditional format.\n\n Do you want to edit the existing conditional format?";
+ };
String STR_QUERY_FORMULA_RECALC_ONLOAD_ODS
{
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index fd8fd81eca4b..0fc5dfc79e7f 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -75,6 +75,7 @@
#include "markdata.hxx"
#include "docpool.hxx"
#include "condformatdlg.hxx"
+#include "attrib.hxx"
#include "globstr.hrc"
#include "scui_def.hxx"
@@ -1761,8 +1762,6 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
case SID_OPENDLG_COLORSCALE:
case SID_OPENDLG_DATABAR:
{
- sal_uInt16 nId = 1;
- pScMod->SetRefDialog( nId, true );
ScRangeList aRangeList;
ScViewData* pData = GetViewData();
@@ -1783,15 +1782,67 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
}
sal_Int32 nKey = 0;
- const ScConditionalFormat* pCondFormat = pDoc->GetCondFormat(aPos.Col(), aPos.Row(), aPos.Tab());
+ const ScPatternAttr* pPattern = pDoc->GetPattern(aPos.Col(), aPos.Row(), aPos.Tab());
+ const std::vector<sal_uInt32>& rCondFormats = static_cast<const ScCondFormatItem&>(pPattern->GetItem(ATTR_CONDITIONAL)).GetCondFormatData();
+ bool bContainsCondFormat = !rCondFormats.empty();
boost::scoped_ptr<ScCondFormatDlg> pCondFormatDlg;
- if(pCondFormat)
+ if(bContainsCondFormat)
{
- const ScRangeList& rCondFormatRange = pCondFormat->GetRange();
- if(rCondFormatRange == aRangeList)
+ ScConditionalFormatList* pList = pDoc->GetCondFormList(aPos.Tab());
+ for (std::vector<sal_uInt32>::const_iterator itr = rCondFormats.begin(), itrEnd = rCondFormats.end();
+ itr != itrEnd; ++itr)
{
- nKey = pCondFormat->GetKey();
- pCondFormatDlg.reset( new ScCondFormatDlg( pTabViewShell->GetDialogParent(), pDoc, pCondFormat, rCondFormatRange, aPos, condformat::dialog::NONE ) );
+ // check if at least one existing conditional format has the same range
+ const ScConditionalFormat* pCondFormat = pList->GetFormat(*itr);
+ const ScRangeList& rCondFormatRange = pCondFormat->GetRange();
+ if(rCondFormatRange == aRangeList)
+ {
+ // found a matching range, edit this conditional format
+ nKey = pCondFormat->GetKey();
+ pCondFormatDlg.reset( new ScCondFormatDlg( pTabViewShell->GetDialogParent(), pDoc, pCondFormat, rCondFormatRange, aPos, condformat::dialog::NONE ) );
+ }
+ }
+
+ // if not found a conditional format ask whether we should edit one of the existing
+ // or should create a new overlapping conditional format
+
+ if(!pCondFormatDlg)
+ {
+ QueryBox aBox( pTabViewShell->GetDialogParent(), WinBits( WB_YES_NO | WB_DEF_YES ),
+ 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)
+ {
+ const ScConditionalFormat* pCondFormat = pList->GetFormat(rCondFormats[0]);
+ assert(pCondFormat);
+ const ScRangeList& rCondFormatRange = pCondFormat->GetRange();
+ pCondFormatDlg.reset( new ScCondFormatDlg( pTabViewShell->GetDialogParent(), pDoc, pCondFormat, rCondFormatRange, aPos, condformat::dialog::NONE ) );
+ }
+ else
+ {
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ boost::scoped_ptr<AbstractScCondFormatManagerDlg> pDlg(pFact->CreateScCondFormatMgrDlg( pTabViewShell->GetDialogParent(), pDoc, pList, aPos, RID_SCDLG_COND_FORMAT_MANAGER));
+ if(pDlg->Execute() == RET_OK && pDlg->CondFormatsChanged())
+ {
+ ScConditionalFormatList* pCondFormatList = pDlg->GetConditionalFormatList();
+ pData->GetDocShell()->GetDocFunc().SetConditionalFormatList(pCondFormatList, aPos.Tab());
+ }
+ // we need step out here because we don't want to open the normal dialog
+ break;
+ }
+ }
+ else
+ {
+ // define an overlapping conditional format
+ // does not need to be handled here
+ }
+
}
}
@@ -1814,6 +1865,10 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
}
pCondFormatDlg.reset( new ScCondFormatDlg( pTabViewShell->GetDialogParent(), pDoc, NULL, aRangeList, aRangeList.GetTopLeftCorner(), eType ) );
}
+
+ sal_uInt16 nId = 1;
+ pScMod->SetRefDialog( nId, true );
+
if( pCondFormatDlg->Execute() == RET_OK )
{
ScConditionalFormat* pFormat = pCondFormatDlg->GetConditionalFormat();