summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-07-02 11:30:28 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-07-04 02:17:25 +0200
commit7d295975c51f198a0e6933f6e4c7d85dfa9e3c8f (patch)
tree6a7f945af0be9fbc77f3a8532e5be768301def5d /sc
parent871111155e302ecaf245003bcd8357e294f8b268 (diff)
add the cond format manager
Change-Id: I2c21b048c24333e4d04434ff92b9d9da2efe9558
Diffstat (limited to 'sc')
-rw-r--r--sc/AllLangResTarget_sc.mk1
-rw-r--r--sc/Library_scui.mk2
-rw-r--r--sc/inc/conditio.hxx2
-rw-r--r--sc/inc/globstr.hrc3
-rw-r--r--sc/inc/sc.hrc3
-rw-r--r--sc/inc/scabstdlg.hxx10
-rw-r--r--sc/sdi/cellsh.sdi1
-rw-r--r--sc/sdi/scalc.sdi25
-rw-r--r--sc/source/ui/attrdlg/scdlgfact.cxx25
-rw-r--r--sc/source/ui/attrdlg/scdlgfact.hxx11
-rw-r--r--sc/source/ui/condformat/condformatdlg.cxx58
-rw-r--r--sc/source/ui/condformat/condformathelper.cxx120
-rw-r--r--sc/source/ui/condformat/condformatmgr.cxx206
-rw-r--r--sc/source/ui/inc/condformatdlg.hxx10
-rw-r--r--sc/source/ui/inc/condformathelper.hxx30
-rw-r--r--sc/source/ui/inc/condformatmgr.hrc18
-rw-r--r--sc/source/ui/inc/condformatmgr.hxx108
-rw-r--r--sc/source/ui/src/condformatmgr.src66
-rw-r--r--sc/source/ui/src/globstr.src4
-rw-r--r--sc/source/ui/view/cellsh1.cxx29
-rw-r--r--sc/uiconfig/scalc/menubar/menubar.xml10
21 files changed, 669 insertions, 73 deletions
diff --git a/sc/AllLangResTarget_sc.mk b/sc/AllLangResTarget_sc.mk
index 1c0eb4d98f1b..2d3c64c89153 100644
--- a/sc/AllLangResTarget_sc.mk
+++ b/sc/AllLangResTarget_sc.mk
@@ -81,6 +81,7 @@ $(eval $(call gb_SrsTarget_add_files,sc/res,\
sc/source/ui/src/filter.src \
sc/source/ui/src/colorformat.src \
sc/source/ui/src/condformatdlg.src \
+ sc/source/ui/src/condformatmgr.src \
sc/source/ui/cctrl/checklistmenu.src \
sc/source/ui/navipi/navipi.src \
sc/source/ui/docshell/tpstat.src \
diff --git a/sc/Library_scui.mk b/sc/Library_scui.mk
index bcde415a7544..3e1a08794716 100644
--- a/sc/Library_scui.mk
+++ b/sc/Library_scui.mk
@@ -62,6 +62,8 @@ $(eval $(call gb_Library_add_exception_objects,scui,\
sc/source/ui/cctrl/editfield \
sc/source/ui/condformat/colorformat \
sc/source/ui/condformat/condformatdlg \
+ sc/source/ui/condformat/condformathelper \
+ sc/source/ui/condformat/condformatmgr \
sc/source/ui/dbgui/dapidata \
sc/source/ui/dbgui/dapitype \
sc/source/ui/dbgui/dpgroupdlg \
diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx
index 2938ca7c54b8..eaeccf5a8f14 100644
--- a/sc/inc/conditio.hxx
+++ b/sc/inc/conditio.hxx
@@ -314,7 +314,7 @@ public:
// List of areas and formats:
//
-class ScConditionalFormatList
+class SC_DLLPUBLIC ScConditionalFormatList
{
private:
boost::ptr_set<ScConditionalFormat> maConditionalFormats;
diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index 28031aac34ef..5ebcb62ddc96 100644
--- a/sc/inc/globstr.hrc
+++ b/sc/inc/globstr.hrc
@@ -589,8 +589,9 @@
#define STR_UNSAVED_EXT_REF 465
#define STR_CLOSE_WITH_UNSAVED_REFS 466
#define STR_PIVOT_GROUP 467
+#define STR_HEADER_COND 468
-#define STR_COUNT 468
+#define STR_COUNT 469
#endif
diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc
index b3f194ae0dad..dc7b2f593727 100644
--- a/sc/inc/sc.hrc
+++ b/sc/inc/sc.hrc
@@ -247,6 +247,7 @@
#define SID_OPENDLG_CONDFRMT (SC_MESSAGE_START + 59)
#define SID_OPENDLG_OPTSOLVER (SC_MESSAGE_START + 60)
#define SID_VALIDITY_REFERENCE (SC_MESSAGE_START + 61)
+#define SID_OPENDLG_CONDFRMT_MANAGER (SC_MESSAGE_START + 62)
#define SC_HINT_NAVIGATOR_UPDATEALL (SC_MESSAGE_START + 65)
// functions
@@ -1080,6 +1081,8 @@
#define RID_COND_ENTRY (SC_DIALOGS_START + 156)
#define RID_SCDLG_FORMULA_CALCOPTIONS (SC_DIALOGS_START + 157)
+#define RID_SCDLG_COND_FORMAT_MANAGER (SC_DIALOGS_START + 158)
+
#define SC_DIALOGS_END (SC_DIALOGS_START + 160)
#ifndef STD_MASKCOLOR
diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx
index 375bb98cfd37..7ecad756e22a 100644
--- a/sc/inc/scabstdlg.hxx
+++ b/sc/inc/scabstdlg.hxx
@@ -57,6 +57,7 @@ struct ScDPFuncData;
struct ScDPNumGroupInfo;
class ScTabViewShell;
class ScConditionalFormat;
+class ScConditionalFormatList;
namespace com { namespace sun { namespace star { namespace sheet {
struct DataPilotFieldReference;
@@ -91,6 +92,12 @@ public:
virtual ScConditionalFormat* GetConditionalFormat() = 0;
};
+class AbstractScCondFormatManagerDlg : public VclAbstractDialog
+{
+public:
+ virtual ScConditionalFormatList* GetConditionalFormatList() = 0;
+};
+
class AbstractScDataBarSettingsDlg : public VclAbstractDialog
{
};
@@ -361,6 +368,9 @@ public:
virtual AbstractScCondFormatDlg* CreateScCondFormatDlg (Window* pParent, ScDocument* pDoc, const ScConditionalFormat* pFormat,
const ScRangeList& rList, const ScAddress& rPos, int nId ) = 0; //add for ScCondFormatDlg
+ virtual AbstractScCondFormatManagerDlg* CreateScCondFormatMgrDlg(Window* pParent, ScDocument* pDoc, const ScConditionalFormatList* pFormatList,
+ const ScRangeList& rList, const ScAddress& rPos, int nId ) = 0;
+
virtual AbstractScDataBarSettingsDlg* CreateScDataBarSetttingsDlg (Window* pParent, ScDocument* pDoc, int nId ) = 0; //add for ScDataBarSettingsDlg
virtual AbstractScDataPilotDatabaseDlg * CreateScDataPilotDatabaseDlg (Window* pParent ,int nId ) = 0; //add for ScDataPilotDatabaseDlg
diff --git a/sc/sdi/cellsh.sdi b/sc/sdi/cellsh.sdi
index 99f3541e55b8..f20b07c4cf36 100644
--- a/sc/sdi/cellsh.sdi
+++ b/sc/sdi/cellsh.sdi
@@ -188,6 +188,7 @@ interface CellSelection
SID_CANCEL [ ExecMethod = Execute; ]
SID_TOGGLE_REL [ ExecMethod = ExecuteEdit; StateMethod = GetState; ]
SID_OPENDLG_CONDFRMT [ ExecMethod = ExecuteEdit; ]
+ SID_OPENDLG_CONDFRMT_MANAGER [ ExecMethod = ExecuteEdit; ]
SID_COLORSCALE [ ExecMethod = ExecuteEdit; ]
SID_DATABAR [ ExecMethod = ExecuteEdit; ]
FID_NOTE_VISIBLE [ ExecMethod = ExecuteEdit; StateMethod = GetState; ]
diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi
index 36f355f1555f..050c64512366 100644
--- a/sc/sdi/scalc.sdi
+++ b/sc/sdi/scalc.sdi
@@ -1094,6 +1094,31 @@ SfxVoidItem ConditionalFormatDialog SID_OPENDLG_CONDFRMT
]
//--------------------------------------------------------------------------
+SfxVoidItem ConditionalFormatManagerDialog SID_OPENDLG_CONDFRMT_MANAGER
+()
+[
+ /* flags: */
+ AutoUpdate = FALSE,
+ Cachable = Cachable,
+ FastCall = FALSE,
+ HasCoreId = FALSE,
+ HasDialog = TRUE,
+ ReadOnlyDoc = TRUE,
+ Toggle = FALSE,
+ Container = FALSE,
+ RecordAbsolute = FALSE,
+ RecordPerSet;
+ Synchron;
+
+ /* config: */
+ AccelConfig = TRUE,
+ MenuConfig = TRUE,
+ StatusBarConfig = FALSE,
+ ToolBoxConfig = TRUE,
+ GroupId = GID_FORMAT;
+]
+
+//--------------------------------------------------------------------------
SfxVoidItem ColorScaleDialog SID_COLORSCALE
()
[
diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx
index 01c3b0839bf5..4dd5292133dd 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -81,6 +81,7 @@
#include "tpdefaults.hxx"
#include "colorformat.hxx"
#include "condformatdlg.hxx"
+#include "condformatmgr.hxx"
// ause
#include "editutil.hxx"
@@ -90,6 +91,7 @@ IMPL_ABSTDLG_BASE(AbstractScImportAsciiDlg_Impl);
IMPL_ABSTDLG_BASE(AbstractScAutoFormatDlg_Impl);
IMPL_ABSTDLG_BASE(AbstractScColRowLabelDlg_Impl);
IMPL_ABSTDLG_BASE(AbstractScCondFormatDlg_Impl);
+IMPL_ABSTDLG_BASE(AbstractScCondFormatManagerDlg_Impl);
IMPL_ABSTDLG_BASE(AbstractScDataBarSettingsDlg_Impl);
IMPL_ABSTDLG_BASE(AbstractScDataPilotDatabaseDlg_Impl);
IMPL_ABSTDLG_BASE(AbstractScDataPilotSourceTypeDlg_Impl);
@@ -460,7 +462,10 @@ ScConditionalFormat* AbstractScCondFormatDlg_Impl::GetConditionalFormat()
return pDlg->GetConditionalFormat();
}
-
+ScConditionalFormatList* AbstractScCondFormatManagerDlg_Impl::GetConditionalFormatList()
+{
+ return pDlg->GetConditionalFormatList();
+}
long AbstractScMetricInputDlg_Impl::GetInputValue( FieldUnit eUnit ) const
@@ -794,6 +799,24 @@ AbstractScCondFormatDlg* ScAbstractDialogFactory_Impl::CreateScCondFormatDlg(Win
return NULL;
}
+AbstractScCondFormatManagerDlg* ScAbstractDialogFactory_Impl::CreateScCondFormatMgrDlg(Window* pParent, ScDocument* pDoc, const ScConditionalFormatList* pFormatList,
+ const ScRangeList& rList, const ScAddress& rPos, int nId )
+{
+ ScCondFormatManagerDlg* pDlg = NULL;
+ switch( nId )
+ {
+ case RID_SCDLG_COND_FORMAT_MANAGER:
+ pDlg = new ScCondFormatManagerDlg( pParent, pDoc, pFormatList, rList, rPos );
+ break;
+ default:
+ break;
+ }
+ if(pDlg)
+ return new AbstractScCondFormatManagerDlg_Impl( pDlg );
+
+ return NULL;
+}
+
AbstractScDataBarSettingsDlg* ScAbstractDialogFactory_Impl::CreateScDataBarSetttingsDlg(Window* pParent, ScDocument* pDoc, int nId)
{
ScDataBarSettingsDlg* pDlg = NULL;
diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx
index 4728f1c079da..fcf000d7fa39 100644
--- a/sc/source/ui/attrdlg/scdlgfact.hxx
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -66,6 +66,7 @@ class SfxTabDialog;
class ScTextImportOptionsDlg;
class ScDataBarSettingsDlg;
class ScCondFormatDlg;
+class ScCondFormatManagerDlg;
#define DECL_ABSTDLG_BASE(Class,DialogClass) \
DialogClass* pDlg; \
@@ -144,6 +145,13 @@ class AbstractScCondFormatDlg_Impl : public AbstractScCondFormatDlg
virtual ScConditionalFormat* GetConditionalFormat();
};
+class AbstractScCondFormatManagerDlg_Impl : public AbstractScCondFormatManagerDlg
+{
+ DECL_ABSTDLG_BASE(AbstractScCondFormatManagerDlg_Impl, ScCondFormatManagerDlg)
+
+ virtual ScConditionalFormatList* GetConditionalFormatList();
+};
+
class AbstractScDataBarSettingsDlg_Impl : public AbstractScDataBarSettingsDlg
{
DECL_ABSTDLG_BASE(AbstractScDataBarSettingsDlg_Impl, ScDataBarSettingsDlg)
@@ -430,6 +438,9 @@ public:
virtual AbstractScCondFormatDlg* CreateScCondFormatDlg(Window* pParent, ScDocument* pDoc, const ScConditionalFormat* pFormat,
const ScRangeList& rRange, const ScAddress& rPos, int nId ); //add for ScDataBarSettingsDlg
+ virtual AbstractScCondFormatManagerDlg* CreateScCondFormatMgrDlg(Window* pParent, ScDocument* pDoc, const ScConditionalFormatList* pFormatList,
+ const ScRangeList& rList, const ScAddress& rPos, int nId );
+
virtual AbstractScDataBarSettingsDlg* CreateScDataBarSetttingsDlg (Window* pParent, ScDocument* pDoc, int nId ); //add for ScDataBarSettingsDlg
virtual AbstractScDataPilotDatabaseDlg * CreateScDataPilotDatabaseDlg (Window* pParent ,int nId ); //add for ScDataPilotDatabaseDlg
diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index 6c4865be1e7d..9e8ca45419cf 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -387,57 +387,6 @@ void ScCondFrmtEntry::Init()
mpDataBarData->maPositiveColor = COL_LIGHTBLUE;
}
-namespace {
-
-rtl::OUString getTextForType(ScCondFormatEntryType eType)
-{
- switch(eType)
- {
- case CONDITION:
- return rtl::OUString("Cell value");
- case COLORSCALE:
- return rtl::OUString("Color scale");
- case DATABAR:
- return rtl::OUString("Data Bar");
- case FORMULA:
- return rtl::OUString("Formula is");
- default:
- break;
- }
-
- return rtl::OUString("");
-}
-
-rtl::OUString getExpression(sal_Int32 nIndex)
-{
- switch(nIndex)
- {
- case 0:
- return rtl::OUString("=");
- case 1:
- return rtl::OUString("<");
- case 2:
- return rtl::OUString(">");
- case 3:
- return rtl::OUString("<=");
- case 4:
- return rtl::OUString(">=");
- case 5:
- return rtl::OUString("!=");
- case 6:
- return rtl::OUString("between");
- case 7:
- return rtl::OUString("not between");
- case 8:
- return rtl::OUString("duplicate");
- case 9:
- return rtl::OUString("unique");
- }
- return rtl::OUString();
-}
-
-}
-
long ScCondFrmtEntry::Notify( NotifyEvent& rNEvt )
{
if( rNEvt.GetType() == EVENT_MOUSEBUTTONDOWN )
@@ -454,11 +403,8 @@ void ScCondFrmtEntry::SwitchToType( ScCondFormatEntryType eType )
case COLLAPSED:
{
maLbType.Hide();
- rtl::OUStringBuffer maCondText(getTextForType(meType));
- maCondText.append(rtl::OUString(" "));
- if(meType == CONDITION)
- maCondText.append(getExpression(maLbCondType.GetSelectEntryPos()));
- maFtCondition.SetText(maCondText.makeStringAndClear());
+ rtl::OUString maCondText = ScCondFormatHelper::GetExpression(meType, maLbCondType.GetSelectEntryPos());
+ maFtCondition.SetText(maCondText);
maFtCondition.Show();
maLbType.Hide();
HideCondElements();
diff --git a/sc/source/ui/condformat/condformathelper.cxx b/sc/source/ui/condformat/condformathelper.cxx
new file mode 100644
index 000000000000..0ef03e83c1af
--- /dev/null
+++ b/sc/source/ui/condformat/condformathelper.cxx
@@ -0,0 +1,120 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <rtl/ustrbuf.hxx>
+#include "condformathelper.hxx"
+
+namespace {
+
+rtl::OUString getTextForType(ScCondFormatEntryType eType)
+{
+ switch(eType)
+ {
+ case CONDITION:
+ return rtl::OUString("Cell value");
+ case COLORSCALE:
+ return rtl::OUString("Color scale");
+ case DATABAR:
+ return rtl::OUString("Data Bar");
+ case FORMULA:
+ return rtl::OUString("Formula is");
+ default:
+ break;
+ }
+
+ return rtl::OUString("");
+}
+
+rtl::OUString getExpression(sal_Int32 nIndex)
+{
+ switch(nIndex)
+ {
+ case 0:
+ return rtl::OUString("=");
+ case 1:
+ return rtl::OUString("<");
+ case 2:
+ return rtl::OUString(">");
+ case 3:
+ return rtl::OUString("<=");
+ case 4:
+ return rtl::OUString(">=");
+ case 5:
+ return rtl::OUString("!=");
+ case 6:
+ return rtl::OUString("between");
+ case 7:
+ return rtl::OUString("not between");
+ case 8:
+ return rtl::OUString("duplicate");
+ case 9:
+ return rtl::OUString("unique");
+ }
+ return rtl::OUString();
+}
+
+}
+
+rtl::OUString ScCondFormatHelper::GetExpression(const ScConditionalFormat& rFormat, const ScAddress& rPos)
+{
+ rtl::OUStringBuffer aBuffer;
+ if(!rFormat.IsEmpty())
+ {
+ switch(rFormat.GetEntry(0)->GetType())
+ {
+ case condformat::CONDITION:
+ {
+ const ScConditionEntry* pEntry = static_cast<const ScConditionEntry*>(rFormat.GetEntry(0));
+ ScConditionMode eMode = pEntry->GetOperation();
+ if(eMode == SC_COND_DIRECT)
+ {
+ aBuffer.append(getTextForType(FORMULA));
+ }
+ else
+ {
+ aBuffer.append(getTextForType(CONDITION));
+ aBuffer.append(rtl::OUString(" "));
+ aBuffer.append(getExpression(static_cast<sal_Int32>(eMode)));
+ aBuffer.append(rtl::OUString(" "));
+ if(eMode == SC_COND_BETWEEN || eMode == SC_COND_NOTBETWEEN)
+ {
+ aBuffer.append(pEntry->GetExpression(rPos, 0));
+ aBuffer.append(rtl::OUString(" and "));
+ aBuffer.append(pEntry->GetExpression(rPos, 1));
+ }
+ else
+ {
+ aBuffer.append(pEntry->GetExpression(rPos, 0));
+ }
+ }
+ }
+
+ break;
+ case condformat::DATABAR:
+ aBuffer.append(getTextForType(DATABAR));
+ break;
+ case condformat::COLORSCALE:
+ aBuffer.append(getTextForType(COLORSCALE));
+ break;
+ }
+ }
+ return aBuffer.makeStringAndClear();
+}
+
+rtl::OUString ScCondFormatHelper::GetExpression( ScCondFormatEntryType eType, sal_Int32 nIndex )
+{
+ rtl::OUStringBuffer aBuffer(getTextForType(eType));
+ aBuffer.append(rtl::OUString(" "));
+ if(eType == CONDITION)
+ aBuffer.append(getExpression(nIndex));
+
+ return aBuffer.makeStringAndClear();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/condformat/condformatmgr.cxx b/sc/source/ui/condformat/condformatmgr.cxx
new file mode 100644
index 000000000000..c8f3ad6c7d13
--- /dev/null
+++ b/sc/source/ui/condformat/condformatmgr.cxx
@@ -0,0 +1,206 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2012 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include "condformatmgr.hxx"
+#include "condformatmgr.hrc"
+#include "scresid.hxx"
+#include "globstr.hrc"
+#include "condformatdlg.hxx"
+#include "vcl/msgbox.hxx"
+
+#define ITEMID_RANGE 1
+#define ITEMID_CONDITION 2
+
+
+ScCondFormatManagerWindow::ScCondFormatManagerWindow(Window* pParent, ScDocument* pDoc, ScConditionalFormatList* pFormatList, const ScAddress& rPos):
+ SvTabListBox(pParent, WB_SORT | WB_HSCROLL | WB_CLIPCHILDREN | WB_TABSTOP),
+ maHeaderBar( pParent, WB_BUTTONSTYLE | WB_BOTTOMBORDER ),
+ mpDoc(pDoc),
+ mpFormatList(pFormatList),
+ mrPos(rPos)
+{
+ Size aBoxSize( pParent->GetOutputSizePixel() );
+
+ maHeaderBar.SetPosSizePixel( Point(0, 0), Size( aBoxSize.Width(), 16 ) );
+
+ String aConditionStr(ScGlobal::GetRscString(STR_HEADER_COND));
+ String aRangeStr(ScGlobal::GetRscString(STR_HEADER_RANGE));
+
+ long nTabSize = aBoxSize.Width()/2;
+ maHeaderBar.InsertItem( ITEMID_RANGE, aRangeStr, nTabSize, HIB_LEFT| HIB_VCENTER );
+ maHeaderBar.InsertItem( ITEMID_CONDITION, aConditionStr, nTabSize, HIB_LEFT| HIB_VCENTER );
+
+ static long nTabs[] = {2, 0, nTabSize };
+ Size aHeadSize( maHeaderBar.GetSizePixel() );
+
+ //pParent->SetFocusControl( this );
+ SetPosSizePixel( Point( 0, aHeadSize.Height() ), Size( aBoxSize.Width(), aBoxSize.Height() - aHeadSize.Height() ) );
+ SetTabs( &nTabs[0], MAP_PIXEL );
+
+ //maHeaderBar.SetEndDragHdl( LINK( this, ScRangeManagerTable, HeaderEndDragHdl ) );
+
+ Init();
+ Show();
+ maHeaderBar.Show();
+ SetSelectionMode(MULTIPLE_SELECTION);
+}
+
+String ScCondFormatManagerWindow::createEntryString(const ScConditionalFormat& rFormat)
+{
+ ScRangeList aRange = rFormat.GetRange();
+ String aStr;
+ aRange.Format(aStr, SCA_VALID, mpDoc, mpDoc->GetAddressConvention());
+ aStr += '\t';
+ aStr += ScCondFormatHelper::GetExpression(rFormat, mrPos);
+ return aStr;
+}
+
+void ScCondFormatManagerWindow::Init()
+{
+ SetUpdateMode(false);
+
+ for(ScConditionalFormatList::iterator itr = mpFormatList->begin(); itr != mpFormatList->end(); ++itr)
+ {
+ SvLBoxEntry* pEntry = InsertEntryToColumn( createEntryString(*itr), LIST_APPEND, 0xffff );
+ maMapLBoxEntryToCondIndex.insert(std::pair<SvLBoxEntry*,sal_Int32>(pEntry,itr->GetKey()));
+ }
+ SetUpdateMode(true);
+}
+
+void ScCondFormatManagerWindow::DeleteSelection()
+{
+ if(GetSelectionCount())
+ {
+ for(SvLBoxEntry* pEntry = FirstSelected(); pEntry != NULL; pEntry = NextSelected(pEntry))
+ {
+ sal_Int32 nIndex = maMapLBoxEntryToCondIndex.find(pEntry)->second;
+ mpFormatList->erase(nIndex);
+ }
+ RemoveSelection();
+ }
+}
+
+ScConditionalFormat* ScCondFormatManagerWindow::GetSelection()
+{
+ SvLBoxEntry* pEntry = FirstSelected();
+ if(!pEntry)
+ return NULL;
+
+ sal_Int32 nIndex = maMapLBoxEntryToCondIndex.find(pEntry)->second;
+ return mpFormatList->GetFormat(nIndex);
+}
+
+void ScCondFormatManagerWindow::Update()
+{
+ Clear();
+ maMapLBoxEntryToCondIndex.clear();
+ Init();
+}
+
+ScCondFormatManagerCtrl::ScCondFormatManagerCtrl(Window* pParent, ScDocument* pDoc, ScConditionalFormatList* pFormatList, const ScAddress& rPos):
+ Control(pParent, ScResId(CTRL_TABLE)),
+ maWdManager(this, pDoc, pFormatList, rPos)
+{
+}
+
+ScConditionalFormat* ScCondFormatManagerCtrl::GetSelection()
+{
+ return maWdManager.GetSelection();
+}
+
+void ScCondFormatManagerCtrl::DeleteSelection()
+{
+ maWdManager.DeleteSelection();
+}
+
+void ScCondFormatManagerCtrl::Update()
+{
+ maWdManager.Update();
+}
+
+ScCondFormatManagerDlg::ScCondFormatManagerDlg(Window* pParent, ScDocument* pDoc, const ScConditionalFormatList* pFormatList, const ScRangeList& rList, const ScAddress& rPos):
+ ModalDialog(pParent, ScResId(RID_SCDLG_COND_FORMAT_MANAGER)),
+ maBtnAdd(this, ScResId(BTN_ADD)),
+ maBtnRemove(this, ScResId(BTN_REMOVE)),
+ maBtnEdit(this, ScResId(BTN_EDIT)),
+ maBtnOk(this, ScResId(BTN_OK)),
+ maBtnCancel(this, ScResId(BTN_CANCEL)),
+ maFlLine(this, ScResId(FL_LINE)),
+ mpFormatList( pFormatList ? new ScConditionalFormatList(*pFormatList) : NULL),
+ maCtrlManager(this, pDoc, mpFormatList, rPos),
+ mpDoc(pDoc),
+ mrRangeList(rList),
+ maPos(rPos)
+{
+ FreeResource();
+
+ maBtnRemove.SetClickHdl(LINK(this, ScCondFormatManagerDlg, RemoveBtnHdl));
+ maBtnEdit.SetClickHdl(LINK(this, ScCondFormatManagerDlg, EditBtnHdl));
+ maBtnAdd.Hide();
+}
+
+ScCondFormatManagerDlg::~ScCondFormatManagerDlg()
+{
+ delete mpFormatList;
+}
+
+ScConditionalFormatList* ScCondFormatManagerDlg::GetConditionalFormatList()
+{
+ ScConditionalFormatList* pList = mpFormatList;
+ mpFormatList = NULL;
+ return pList;
+}
+
+IMPL_LINK_NOARG(ScCondFormatManagerDlg, RemoveBtnHdl)
+{
+ maCtrlManager.DeleteSelection();
+ return 0;
+}
+
+IMPL_LINK_NOARG(ScCondFormatManagerDlg, EditBtnHdl)
+{
+ ScConditionalFormat* pFormat = maCtrlManager.GetSelection();
+
+ if(!pFormat)
+ return 0;
+
+ ScCondFormatDlg* pDlg = new ScCondFormatDlg(this, mpDoc, pFormat, pFormat->GetRange(), maPos);
+ if(pDlg->Execute() == RET_OK)
+ {
+ sal_Int32 nKey = pFormat->GetKey();
+ mpFormatList->erase(nKey);
+ ScConditionalFormat* pNewFormat = pDlg->GetConditionalFormat();
+ pNewFormat->SetKey(nKey);
+ mpFormatList->InsertNew(pNewFormat);
+ maCtrlManager.Update();
+ }
+
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/condformatdlg.hxx b/sc/source/ui/inc/condformatdlg.hxx
index d7b10e19a22b..8015b263805e 100644
--- a/sc/source/ui/inc/condformatdlg.hxx
+++ b/sc/source/ui/inc/condformatdlg.hxx
@@ -36,6 +36,7 @@
#include <svtools/ctrlbox.hxx>
#include "rangelst.hxx"
+#include "condformathelper.hxx"
#include <boost/ptr_container/ptr_vector.hpp>
#include <boost/scoped_ptr.hpp>
@@ -46,15 +47,6 @@ class ScFormatEntry;
class ScConditionalFormat;
struct ScDataBarFormatData;
-enum ScCondFormatEntryType
-{
- CONDITION,
- COLORSCALE,
- DATABAR,
- FORMULA,
- COLLAPSED
-};
-
class ScCondFrmtEntry : public Control
{
private:
diff --git a/sc/source/ui/inc/condformathelper.hxx b/sc/source/ui/inc/condformathelper.hxx
new file mode 100644
index 000000000000..99f5b59cdfb1
--- /dev/null
+++ b/sc/source/ui/inc/condformathelper.hxx
@@ -0,0 +1,30 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <rtl/ustring.hxx>
+#include "conditio.hxx"
+
+enum ScCondFormatEntryType
+{
+ CONDITION,
+ COLORSCALE,
+ DATABAR,
+ FORMULA,
+ COLLAPSED
+};
+
+class ScCondFormatHelper
+{
+public:
+ static rtl::OUString GetExpression(const ScConditionalFormat& rFormat, const ScAddress& rPos);
+
+ static rtl::OUString GetExpression( ScCondFormatEntryType eType, sal_Int32 nIndex );
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/condformatmgr.hrc b/sc/source/ui/inc/condformatmgr.hrc
new file mode 100644
index 000000000000..7fb10c7f0e9d
--- /dev/null
+++ b/sc/source/ui/inc/condformatmgr.hrc
@@ -0,0 +1,18 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#define BTN_OK 1
+#define BTN_CANCEL 2
+#define BTN_ADD 3
+#define BTN_REMOVE 4
+#define BTN_EDIT 5
+#define FL_LINE 6
+#define CTRL_TABLE 8
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/condformatmgr.hxx b/sc/source/ui/inc/condformatmgr.hxx
new file mode 100644
index 000000000000..bf7cfb313483
--- /dev/null
+++ b/sc/source/ui/inc/condformatmgr.hxx
@@ -0,0 +1,108 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2012 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include "sc.hrc"
+
+#include <vcl/dialog.hxx>
+#include <svtools/svtabbx.hxx>
+#include <vcl/button.hxx>
+#include <vcl/fixed.hxx>
+#include <svtools/headbar.hxx>
+
+#include "conditio.hxx"
+#include "rangelst.hxx"
+#include "document.hxx"
+
+#include <map>
+
+class ScDocument;
+
+class ScCondFormatManagerWindow : public SvTabListBox
+{
+private:
+ void Init();
+ String createEntryString(const ScConditionalFormat& rFormat);
+
+ HeaderBar maHeaderBar;
+ ScDocument* mpDoc;
+ ScConditionalFormatList* mpFormatList;
+ const ScAddress& mrPos;
+ std::map<SvLBoxEntry*, sal_Int32> maMapLBoxEntryToCondIndex;
+
+public:
+ ScCondFormatManagerWindow( Window* pParent, ScDocument* pDoc, ScConditionalFormatList* pFormatList, const ScAddress& rPos );
+
+ void DeleteSelection();
+ ScConditionalFormat* GetSelection();
+ void Update();
+};
+
+class ScCondFormatManagerCtrl : Control
+{
+public:
+ ScCondFormatManagerCtrl(Window* pParent, ScDocument* pDoc, ScConditionalFormatList* pFormatList, const ScAddress& rPos);
+
+ ScConditionalFormat* GetSelection();
+ void DeleteSelection();
+ void Update();
+
+private:
+ ScCondFormatManagerWindow maWdManager;
+};
+
+class ScCondFormatManagerDlg : public ModalDialog
+{
+public:
+ ScCondFormatManagerDlg(Window* pParent, ScDocument* pDoc, const ScConditionalFormatList* pFormatList, const ScRangeList& rList, const ScAddress& rPos);
+ ~ScCondFormatManagerDlg();
+
+ ScConditionalFormatList* GetConditionalFormatList();
+
+private:
+ PushButton maBtnAdd;
+ PushButton maBtnRemove;
+ PushButton maBtnEdit;
+
+ OKButton maBtnOk;
+ CancelButton maBtnCancel;
+
+ FixedLine maFlLine;
+
+ ScConditionalFormatList* mpFormatList;
+
+ ScCondFormatManagerCtrl maCtrlManager;
+
+ ScDocument* mpDoc;
+ const ScRangeList& mrRangeList;
+ ScAddress maPos;
+
+ DECL_LINK(RemoveBtnHdl, void*);
+ DECL_LINK(EditBtnHdl, void*);
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/src/condformatmgr.src b/sc/source/ui/src/condformatmgr.src
new file mode 100644
index 000000000000..9009d213e4ba
--- /dev/null
+++ b/sc/source/ui/src/condformatmgr.src
@@ -0,0 +1,66 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "sc.hrc"
+#include "condformatmgr.hrc"
+
+ModalDialog RID_SCDLG_COND_FORMAT_MANAGER
+{
+ OutputSize = TRUE;
+ Hide = TRUE;
+ Size = MAP_APPFONT ( 300, 275 );
+ Text [ en-US ] = "Manage Conditional Formatting";
+ Moveable = TRUE;
+ Closeable = TRUE;
+ OkButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 190, 255 );
+ Size = MAP_APPFONT ( 50, 14 );
+ TabStop = TRUE;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 245, 255 );
+ Size = MAP_APPFONT ( 50, 14 );
+ TabStop = TRUE;
+ };
+ PushButton BTN_ADD
+ {
+ Pos = MAP_APPFONT( 5, 230 );
+ Size = MAP_APPFONT( 40, 14 );
+ Text [ en-US ] = "Add";
+ TabStop = TRUE;
+ };
+ PushButton BTN_REMOVE
+ {
+ Pos = MAP_APPFONT( 95, 230 );
+ Size = MAP_APPFONT( 40, 14 );
+ Text [ en-US ] = "Remove";
+ TabStop = TRUE;
+ };
+ Control CTRL_TABLE
+ {
+ Pos = MAP_APPFONT( 5, 5 );
+ Size = MAP_APPFONT( 290, 220 );
+ Border = TRUE;
+ };
+ PushButton BTN_EDIT
+ {
+ Pos = MAP_APPFONT( 50, 230 );
+ Size = MAP_APPFONT( 40, 14 );
+ Text [ en-US ] = "Edit...";
+ };
+ FixedLine FL_LINE
+ {
+ Pos = MAP_APPFONT( 0, 250 );
+ Size = MAP_APPFONT( 300, 2 );
+ };
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/src/globstr.src b/sc/source/ui/src/globstr.src
index dcc4adb67c8b..4b2a4ecae4f3 100644
--- a/sc/source/ui/src/globstr.src
+++ b/sc/source/ui/src/globstr.src
@@ -1859,5 +1859,9 @@ Resource RID_GLOBSTR
{
Text [ en-US ] = "This Document is referenced by another document and not yet saved. Closing it without saving will result in data loss.";
};
+ String STR_HEADER_COND
+ {
+ Text [ en_US ] = "First Condition";
+ };
};
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 7ce2a6a55ed0..ee6d5bd9a4a0 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -2061,7 +2061,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
{
pDlg = pFact->CreateScCondFormatDlg( pTabViewShell->GetDialogParent(), pDoc, NULL, aRangeList, aPos, RID_SCDLG_CONDFORMAT );
}
- OSL_ENSURE(pDlg, "Dialog create fail!");
+
if(pDlg->Execute() == RET_OK)
{
ScConditionalFormat* pFormat = pDlg->GetConditionalFormat();
@@ -2074,6 +2074,33 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
}
break;
+ case SID_OPENDLG_CONDFRMT_MANAGER:
+ {
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
+
+ ScRangeList aRangeList;
+ ScViewData* pData = GetViewData();
+ pData->GetMarkData().FillRangeListWithMarks(&aRangeList, false);
+ ScDocument* pDoc = pData->GetDocument();
+
+ ScAddress aPos(pData->GetCurX(), pData->GetCurY(), pData->GetTabNo());
+ if(aRangeList.empty())
+ {
+ ScRange* pRange = new ScRange(aPos);
+ aRangeList.push_back(pRange);
+ }
+
+ ScConditionalFormatList* pList = pDoc->GetCondFormList( aPos.Tab() );
+ AbstractScCondFormatManagerDlg* pDlg = pFact->CreateScCondFormatMgrDlg( pTabViewShell->GetDialogParent(), pDoc, pList, aRangeList, aPos, RID_SCDLG_COND_FORMAT_MANAGER);
+ if(pDlg->Execute() == RET_OK)
+ {
+ pDoc->SetCondFormList(pDlg->GetConditionalFormatList(), aPos.Tab());
+ }
+ delete pDlg;
+ }
+ break;
+
case SID_COLORSCALE:
{
ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
diff --git a/sc/uiconfig/scalc/menubar/menubar.xml b/sc/uiconfig/scalc/menubar/menubar.xml
index ff7b3270c006..8feb89ea407d 100644
--- a/sc/uiconfig/scalc/menubar/menubar.xml
+++ b/sc/uiconfig/scalc/menubar/menubar.xml
@@ -273,10 +273,12 @@
<menu:menuitem menu:id=".uno:DesignerDialog"/>
<menu:menuitem menu:id=".uno:AutoFormat"/>
<menu:menu menu:id=".uno:ConditionalFormatMenu">
- <menu:menupopup>
- <menu:menuitem menu:id=".uno:ConditionalFormatDialog"/>
- </menu:menupopup>
- </menu:menu>
+ <menu:menupopup>
+ <menu:menuitem menu:id=".uno:ConditionalFormatDialog"/>
+ <menu:menuseparator/>
+ <menu:menuitem menu:id=".uno:ConditionalFormatManagerDialog"/>
+ </menu:menupopup>
+ </menu:menu>
<menu:menuseparator/>
<menu:menu menu:id=".uno:AnchorMenu">
<menu:menupopup>