summaryrefslogtreecommitdiff
path: root/sc/source/ui/namedlg
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2011-12-03 18:42:04 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2011-12-03 20:15:01 +0100
commit3b0d01a8cb6f9230db400c92a59bf805bcd5bc05 (patch)
treeaa1bf43fb02a86c8a1dd64e616969d1349fe434c /sc/source/ui/namedlg
parentc8fd64a7d909036c4b701d3aaee11b37f378bcce (diff)
ManageNames: make the add button usable
the concept is not perfect and the code looks ugly but we have no way at the moment to open two Refdialogs at the same time REVERT this hack as soon as this is possible!
Diffstat (limited to 'sc/source/ui/namedlg')
-rw-r--r--sc/source/ui/namedlg/namedefdlg.cxx26
-rw-r--r--sc/source/ui/namedlg/namedlg.cxx48
2 files changed, 59 insertions, 15 deletions
diff --git a/sc/source/ui/namedlg/namedefdlg.cxx b/sc/source/ui/namedlg/namedefdlg.cxx
index 90473fda9ab9..b373a1b19d6f 100644
--- a/sc/source/ui/namedlg/namedefdlg.cxx
+++ b/sc/source/ui/namedlg/namedefdlg.cxx
@@ -37,6 +37,7 @@
#include "rangenam.hxx"
#include "reffact.hxx"
#include "undorangename.hxx"
+#include "tabvwsh.hxx"
// defines -------------------------------------------------------------------
@@ -121,7 +122,13 @@ ScNameDefDlg::ScNameDefDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParen
void ScNameDefDlg::CancelPushed()
{
- Close();
+ if (mbUndo)
+ Close();
+ else
+ {
+ ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
+ pViewSh->SwitchBetweenRefDialogs(this);
+ }
}
bool ScNameDefDlg::IsFormulaValid()
@@ -254,9 +261,16 @@ void ScNameDefDlg::AddPushed()
// call invalidates the stream
if (nTab != -1)
mpDoc->SetStreamValid(nTab, false);
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREAS_CHANGED ) );
+ Close();
+ }
+ else
+ {
+ maName = aName;
+ maScope = aScope;
+ ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
+ pViewSh->SwitchBetweenRefDialogs(this);
}
- SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREAS_CHANGED ) );
- Close();
}
else
{
@@ -269,6 +283,12 @@ void ScNameDefDlg::AddPushed()
}
}
+void ScNameDefDlg::GetNewData(rtl::OUString& rName, rtl::OUString& rScope)
+{
+ rName = maName;
+ rScope = maScope;
+}
+
sal_Bool ScNameDefDlg::IsRefInputMode() const
{
return maEdRange.IsEnabled();
diff --git a/sc/source/ui/namedlg/namedlg.cxx b/sc/source/ui/namedlg/namedlg.cxx
index 19eb1694a2dd..93456b551433 100644
--- a/sc/source/ui/namedlg/namedlg.cxx
+++ b/sc/source/ui/namedlg/namedlg.cxx
@@ -42,6 +42,7 @@
#include "namedlg.hrc"
#include "namedlg.hxx"
#include "viewdata.hxx"
+#include "tabvwsh.hxx"
#include "globalnames.hxx"
@@ -68,7 +69,7 @@
ScNameDlg::ScNameDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
ScViewData* ptrViewData,
- const ScAddress& aCursorPos )
+ const ScAddress& aCursorPos, boost::ptr_map<rtl::OUString, ScRangeName>* pRangeMap )
: ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_NAMES ),
//
@@ -107,8 +108,24 @@ ScNameDlg::ScNameDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
mpDoc ( ptrViewData->GetDocument() ),
maCursorPos ( aCursorPos ),
mbNeedUpdate ( true ),
- mbDataChanged ( false )
+ mbDataChanged ( false ),
+ mbCloseWithoutUndo( false )
{
+ if (!pRangeMap)
+ {
+ std::map<rtl::OUString, ScRangeName*> aRangeMap;
+ mpDoc->GetRangeNameMap(aRangeMap);
+ std::map<rtl::OUString, ScRangeName*>::iterator itr = aRangeMap.begin(), itrEnd = aRangeMap.end();
+ for (; itr != itrEnd; ++itr)
+ {
+ rtl::OUString aTemp(itr->first);
+ maRangeMap.insert(aTemp, new ScRangeName(*itr->second));
+ }
+ }
+ else
+ {
+ maRangeMap.swap(*pRangeMap);
+ }
Init();
FreeResource();
}
@@ -125,14 +142,7 @@ void ScNameDlg::Init()
OSL_ENSURE( mpViewData && mpDoc, "ViewData oder Document nicht gefunden!" );
//init UI
- std::map<rtl::OUString, ScRangeName*> aRangeMap;
- mpDoc->GetRangeNameMap(aRangeMap);
- std::map<rtl::OUString, ScRangeName*>::iterator itr = aRangeMap.begin(), itrEnd = aRangeMap.end();
- for (; itr != itrEnd; ++itr)
- {
- rtl::OUString aTemp(itr->first);
- maRangeMap.insert(aTemp, new ScRangeName(*itr->second));
- }
+
mpRangeManagerTable = new ScRangeManagerTable(&maNameMgrCtrl, maRangeMap);
mpRangeManagerTable->SetSelectHdl( LINK( this, ScNameDlg, SelectionChangedHdl_Impl ) );
@@ -178,7 +188,7 @@ void ScNameDlg::Init()
CheckForEmptyTable();
//TODO: fix the Add Button
- maBtnAdd.Disable();
+ //maBtnAdd.Disable();
}
sal_Bool ScNameDlg::IsRefInputMode() const
@@ -207,7 +217,7 @@ void ScNameDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
sal_Bool ScNameDlg::Close()
{
- if (mbDataChanged)
+ if (mbDataChanged && !mbCloseWithoutUndo)
{
ScDocFunc aFunc(*mpViewData->GetDocShell());
aFunc.ModifyAllRangeNames(maRangeMap);
@@ -345,9 +355,18 @@ void ScNameDlg::ShowOptions(const ScRangeNameLine& rLine)
bool ScNameDlg::AddPushed()
{
+ mbCloseWithoutUndo = true;
+ ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
+ pViewSh->SwitchBetweenRefDialogs(this);
return false;
}
+void ScNameDlg::SetEntry(const rtl::OUString& rName, const rtl::OUString& rScope)
+{
+ if (!rName.isEmpty())
+ mbDataChanged = true;
+}
+
void ScNameDlg::RemovePushed()
{
std::vector<ScRangeNameLine> maEntries = mpRangeManagerTable->GetSelectedEntries();
@@ -511,6 +530,11 @@ void ScNameDlg::MorePushed()
MoveWindow(maFlDiv, nPixel);
}
+void ScNameDlg::GetRangeNames(boost::ptr_map<rtl::OUString, ScRangeName>& rRangeMap)
+{
+ maRangeMap.swap(rRangeMap);
+}
+
IMPL_LINK( ScNameDlg, OkBtnHdl, void *, EMPTYARG )
{
Close();