[Libreoffice-commits] .: 3 commits - sc/inc sc/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri Dec 14 22:48:45 PST 2012
sc/inc/globstr.hrc | 11 ++-
sc/source/filter/xml/xmlstyli.cxx | 1
sc/source/ui/condformat/condformatdlg.cxx | 8 ++
sc/source/ui/condformat/condformatdlgentry.cxx | 17 ++---
sc/source/ui/src/globstr.src | 4 +
sc/source/ui/view/cellsh1.cxx | 71 ++++++++++++++++++++++---
6 files changed, 87 insertions(+), 25 deletions(-)
New commits:
commit 89872cc04d8c7053c35eee21509706fd4ee53c5a
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Dec 14 16:50:09 2012 +0100
no need for this using statement
Change-Id: Ie956d5368560d6851f3bcb5174d712e35f09c368
diff --git a/sc/source/filter/xml/xmlstyli.cxx b/sc/source/filter/xml/xmlstyli.cxx
index dae4aa9..a479283 100644
--- a/sc/source/filter/xml/xmlstyli.cxx
+++ b/sc/source/filter/xml/xmlstyli.cxx
@@ -70,7 +70,6 @@ using namespace ::com::sun::star::container;
using namespace xmloff::token;
using namespace ::formula;
-using rtl::OUString;
using com::sun::star::uno::Reference;
using com::sun::star::uno::UNO_QUERY;
commit 4578832a84b1818943da907c4e292af64c49beee
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Dec 14 10:29:48 2012 +0100
use correct cond format dlg setUp for colorscales, fdo#58232
Change-Id: Ib119b09b110d6563bc0abd304f60031a8592d7f1
diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index 6236432..c9667ce 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -84,7 +84,13 @@ ScCondFormatList::ScCondFormatList(Window* pParent, const ResId& rResId, ScDocum
}
break;
case condformat::COLORSCALE:
- maEntries.push_back(new ScColorScale3FrmtEntry( this, mpDoc, maPos, static_cast<const ScColorScaleFormat*>( pEntry ) ) );
+ {
+ const ScColorScaleFormat* pColorScale = static_cast<const ScColorScaleFormat*>( pEntry );
+ if( pColorScale->size() == 2 )
+ maEntries.push_back(new ScColorScale2FrmtEntry( this, mpDoc, maPos, pColorScale ) );
+ else
+ maEntries.push_back(new ScColorScale3FrmtEntry( this, mpDoc, maPos, pColorScale ) );
+ }
break;
case condformat::DATABAR:
maEntries.push_back(new ScDataBarFrmtEntry( this, mpDoc, maPos, static_cast<const ScDataBarFormat*>( pEntry ) ) );
diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx b/sc/source/ui/condformat/condformatdlgentry.cxx
index 96c9bda..3c27da6 100644
--- a/sc/source/ui/condformat/condformatdlgentry.cxx
+++ b/sc/source/ui/condformat/condformatdlgentry.cxx
@@ -582,7 +582,10 @@ namespace {
void SetColorScaleEntryTypes( const ScColorScaleEntry& rEntry, ListBox& rLbType, Edit& rEdit, ColorListBox& rLbCol )
{
- rLbType.SelectEntryPos(rEntry.GetType());
+ // entry Automatic is not available for color scales
+ sal_Int32 nIndex = static_cast<sal_Int32>(rEntry.GetType());
+ assert(nIndex > 0);
+ rLbType.SelectEntryPos(nIndex - 1);
switch(rEntry.GetType())
{
case COLORSCALE_MIN:
@@ -818,17 +821,11 @@ ScColorScale3FrmtEntry::ScColorScale3FrmtEntry( Window* pParent, ScDocument* pDo
maLbType.SelectEntryPos(0);
if(pFormat)
{
- if(pFormat->size() == 2)
- maLbColorFormat.SelectEntryPos(0);
- else
- maLbColorFormat.SelectEntryPos(1);
ScColorScaleFormat::const_iterator itr = pFormat->begin();
SetColorScaleEntryTypes(*itr, maLbEntryTypeMin, maEdMin, maLbColMin);
- if(pFormat->size() == 3)
- {
- ++itr;
- SetColorScaleEntryTypes(*itr, maLbEntryTypeMiddle, maEdMiddle, maLbColMiddle);
- }
+ assert(pFormat->size() == 3);
+ ++itr;
+ SetColorScaleEntryTypes(*itr, maLbEntryTypeMiddle, maEdMiddle, maLbColMiddle);
++itr;
SetColorScaleEntryTypes(*itr, maLbEntryTypeMax, maEdMax, maLbColMax);
}
commit 7073310431becb1a69af0c7187b9844ce7901cd5
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Dec 14 10:03:05 2012 +0100
make editing conditional formats more obvious, related fdo#57895
Change-Id: I2ea95a204fbbd0d36a8fb1374e41aa5aae3cf410
diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index c1873b5..e860a6b 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 88cb11c..955dcb5 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 fd8fd81..0fc5dfc 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();
More information about the Libreoffice-commits
mailing list