Kaydet (Commit) b5a509e2 authored tarafından Markus Mohrhard's avatar Markus Mohrhard

ManageNames: improve layout of ManageNames dialog

üst ce26c58c
...@@ -31,8 +31,8 @@ ...@@ -31,8 +31,8 @@
#define BTN_HELP 5 #define BTN_HELP 5
#define BTN_MORE 6 #define BTN_MORE 6
#define BTN_DELETE 57 #define BTN_DELETE 57
#define BTN_CLOSE 62 #define BTN_NAME_OK 62
#define BTN_CANCEL 73 #define BTN_NAME_CANCEL 73
#define BTN_SELECT 74 #define BTN_SELECT 74
#define FT_SCOPE 7 #define FT_SCOPE 7
...@@ -57,5 +57,8 @@ ...@@ -57,5 +57,8 @@
#define STR_HEADER_NAME 69 #define STR_HEADER_NAME 69
#define STR_HEADER_RANGE 70 #define STR_HEADER_RANGE 70
#define STR_HEADER_SCOPE 71 #define STR_HEADER_SCOPE 71
#define STR_ERR_NAME_EXISTS 73
#define STR_ERR_NAME_INVALID 74
#define STR_DEFAULT_INFO 75
#define FT_INFO_LINE 72 #define FT_INFO 72
...@@ -86,19 +86,25 @@ private: ...@@ -86,19 +86,25 @@ private:
PushButton maBtnAdd; PushButton maBtnAdd;
PushButton maBtnDelete; PushButton maBtnDelete;
PushButton maBtnSelect; PushButton maBtnSelect;
OKButton maBtnOk; PushButton maBtnOk;
CancelButton maBtnCancel; PushButton maBtnCancel;
MoreButton maBtnMore; MoreButton maBtnMore;
FixedText maFtInfo;
const String mErrMsgInvalidSym; const String mErrMsgInvalidSym;
const rtl::OUString maErrMsgModifiedFailed; const rtl::OUString maErrMsgModifiedFailed;
const ::rtl::OUString maGlobalNameStr; const ::rtl::OUString maGlobalNameStr;
const rtl::OUString maErrInvalidNameStr;
const rtl::OUString maErrNameInUse;
const rtl::OUString maStrInfoDefault;
ScViewData* mpViewData; ScViewData* mpViewData;
ScDocument* mpDoc; ScDocument* mpDoc;
const ScAddress maCursorPos; const ScAddress maCursorPos;
Selection maCurSel; Selection maCurSel;
std::map<rtl::OUString, ScRangeName*> maRangeMap;
private: private:
void Init(); void Init();
void UpdateChecks(ScRangeData* pData); void UpdateChecks(ScRangeData* pData);
...@@ -106,6 +112,8 @@ private: ...@@ -106,6 +112,8 @@ private:
void UpdateNames(); void UpdateNames();
void CalcCurTableAssign( String& aAssign, ScRangeData* pRangeData ); void CalcCurTableAssign( String& aAssign, ScRangeData* pRangeData );
bool IsNameValid();
bool AddPushed(); bool AddPushed();
void RemovePushed(); void RemovePushed();
......
...@@ -45,6 +45,8 @@ ...@@ -45,6 +45,8 @@
#include "namedlg.hxx" #include "namedlg.hxx"
#include "viewdata.hxx" #include "viewdata.hxx"
#include "globalnames.hxx"
#include "sfx2/app.hxx" #include "sfx2/app.hxx"
#include <vcl/msgbox.hxx> #include <vcl/msgbox.hxx>
...@@ -115,13 +117,17 @@ ScNameDlg::ScNameDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent, ...@@ -115,13 +117,17 @@ ScNameDlg::ScNameDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
maBtnAdd ( this, ScResId( BTN_ADD ) ), maBtnAdd ( this, ScResId( BTN_ADD ) ),
maBtnDelete ( this, ScResId( BTN_DELETE ) ), maBtnDelete ( this, ScResId( BTN_DELETE ) ),
maBtnSelect ( this, ScResId( BTN_SELECT ) ), maBtnSelect ( this, ScResId( BTN_SELECT ) ),
maBtnOk ( this, ScResId( BTN_CLOSE ) ), maBtnOk ( this, ScResId( BTN_NAME_OK ) ),
maBtnCancel ( this, ScResId( BTN_CANCEL ) ), maBtnCancel ( this, ScResId( BTN_NAME_CANCEL ) ),
maBtnMore ( this, ScResId( BTN_MORE ) ), maBtnMore ( this, ScResId( BTN_MORE ) ),
maFtInfo ( this, ScResId( FT_INFO ) ),
// //
mErrMsgInvalidSym( ScResId( STR_INVALIDSYMBOL ) ), mErrMsgInvalidSym( ScResId( STR_INVALIDSYMBOL ) ),
maErrMsgModifiedFailed( ResId::toString(ScResId( STR_MODIFYFAILED ) ) ), maErrMsgModifiedFailed( ResId::toString(ScResId( STR_MODIFYFAILED ) ) ),
maGlobalNameStr( ResId::toString(ScResId(STR_GLOBAL_SCOPE)) ), maGlobalNameStr ( ResId::toString(ScResId(STR_GLOBAL_SCOPE)) ),
maErrInvalidNameStr( ResId::toString(ScResId(STR_ERR_NAME_INVALID))),
maErrNameInUse ( ResId::toString(ScResId(STR_ERR_NAME_EXISTS))),
maStrInfoDefault ( ResId::toString(ScResId(STR_DEFAULT_INFO))),
// //
mpViewData ( ptrViewData ), mpViewData ( ptrViewData ),
mpDoc ( ptrViewData->GetDocument() ), mpDoc ( ptrViewData->GetDocument() ),
...@@ -144,9 +150,8 @@ void ScNameDlg::Init() ...@@ -144,9 +150,8 @@ void ScNameDlg::Init()
OSL_ENSURE( mpViewData && mpDoc, "ViewData oder Document nicht gefunden!" ); OSL_ENSURE( mpViewData && mpDoc, "ViewData oder Document nicht gefunden!" );
//init UI //init UI
std::map<rtl::OUString,ScRangeName*> aTabRangeNameMap; mpDoc->GetRangeNameMap(maRangeMap);
mpDoc->GetTabRangeNameMap(aTabRangeNameMap); mpRangeManagerTable = new ScRangeManagerTable(&maNameMgrCtrl, mpDoc->GetRangeName(), maRangeMap);
mpRangeManagerTable = new ScRangeManagerTable(&maNameMgrCtrl, mpDoc->GetRangeName(), aTabRangeNameMap);
mpRangeManagerTable->SetSelectHdl( LINK( this, ScNameDlg, SelectionChangedHdl_Impl ) ); mpRangeManagerTable->SetSelectHdl( LINK( this, ScNameDlg, SelectionChangedHdl_Impl ) );
mpRangeManagerTable->SetDeselectHdl( LINK( this, ScNameDlg, SelectionChangedHdl_Impl ) ); mpRangeManagerTable->SetDeselectHdl( LINK( this, ScNameDlg, SelectionChangedHdl_Impl ) );
...@@ -182,6 +187,7 @@ void ScNameDlg::Init() ...@@ -182,6 +187,7 @@ void ScNameDlg::Init()
} }
UpdateNames(); UpdateNames();
IsNameValid();
mpViewData->GetSimpleArea( aRange ); mpViewData->GetSimpleArea( aRange );
aRange.Format( aAreaStr, ABS_DREF3D, mpDoc, aRange.Format( aAreaStr, ABS_DREF3D, mpDoc,
...@@ -244,6 +250,38 @@ void ScNameDlg::UpdateChecks(ScRangeData* pData) ...@@ -244,6 +250,38 @@ void ScNameDlg::UpdateChecks(ScRangeData* pData)
maBtnRowHeader.Check( pData->HasType( RT_ROWHEADER ) ); maBtnRowHeader.Check( pData->HasType( RT_ROWHEADER ) );
} }
bool ScNameDlg::IsNameValid()
{
rtl::OUString aScope = maLbScope.GetSelectEntry();
rtl::OUString aName = maEdName.GetText();
ScRangeName* pRangeName = NULL;
if(aScope == maGlobalNameStr)
{
pRangeName = maRangeMap.find(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(STR_GLOBAL_RANGE_NAME)))->second;
}
else
{
pRangeName = maRangeMap.find(aScope)->second;
}
if (!ScRangeData::IsNameValid( aName, mpDoc ))
{
maEdName.SetControlBackground(GetSettings().GetStyleSettings().GetHighlightColor());
maFtInfo.SetText(maErrInvalidNameStr);
return false;
}
else if (pRangeName && pRangeName->findByUpperName(ScGlobal::pCharClass->upper(aName)))
{
maEdName.SetControlBackground(GetSettings().GetStyleSettings().GetHighlightColor());
maFtInfo.SetText(maErrNameInUse);
return false;
}
maEdName.SetControlBackground(GetSettings().GetStyleSettings().GetFieldColor());
maFtInfo.SetText( maStrInfoDefault );
return true;
}
//updates the table and the buttons //updates the table and the buttons
void ScNameDlg::UpdateNames() void ScNameDlg::UpdateNames()
{ {
...@@ -366,6 +404,7 @@ void ScNameDlg::RemovePushed() ...@@ -366,6 +404,7 @@ void ScNameDlg::RemovePushed()
void ScNameDlg::NameModified() void ScNameDlg::NameModified()
{ {
IsNameValid();
rtl::OUString aName = maEdName.GetText(); rtl::OUString aName = maEdName.GetText();
aName = aName.trim(); aName = aName.trim();
rtl::OUString aExpr = maEdAssign.GetText(); rtl::OUString aExpr = maEdAssign.GetText();
......
...@@ -46,37 +46,37 @@ ModelessDialog RID_SCDLG_NAMES ...@@ -46,37 +46,37 @@ ModelessDialog RID_SCDLG_NAMES
{ {
HelpID = "sc:PushButton:RID_SCDLG_NAMES:BTN_ADD"; HelpID = "sc:PushButton:RID_SCDLG_NAMES:BTN_ADD";
Pos = MAP_APPFONT ( 6 , 200 ) ; Pos = MAP_APPFONT ( 6 , 200 ) ;
Size = MAP_APPFONT ( 50 , 14 ) ; Size = MAP_APPFONT ( 40 , 14 ) ;
Text [ en-US ] = "Add" ; Text [ en-US ] = "Add" ;
TabStop = TRUE ; TabStop = TRUE ;
DefButton = TRUE ; DefButton = TRUE ;
}; };
PushButton BTN_DELETE PushButton BTN_DELETE
{ {
Pos = MAP_APPFONT( 168, 200) ; Pos = MAP_APPFONT( 50, 200) ;
Size = MAP_APPFONT ( 50, 14 ) ; Size = MAP_APPFONT ( 40, 14 ) ;
Text [ en-US ] = "~Delete" ; Text [ en-US ] = "~Delete" ;
TabStop = TRUE ; TabStop = TRUE ;
}; };
PushButton BTN_CLOSE PushButton BTN_NAME_OK
{ {
Pos = MAP_APPFONT ( 108 , 225 ) ; Pos = MAP_APPFONT ( 128 , 225 ) ;
Size = MAP_APPFONT ( 50 , 14 ) ; Size = MAP_APPFONT ( 40 , 14 ) ;
Text [ en-US ] = "Close" ; Text [ en-US ] = "OK" ;
TabStop = TRUE ; TabStop = TRUE ;
}; };
PushButton BTN_CANCEL PushButton BTN_NAME_CANCEL
{ {
Pos = MAP_APPFONT ( 168 , 225 ) ; Pos = MAP_APPFONT ( 178 , 225 ) ;
Size = MAP_APPFONT ( 50 , 14 ) ; Size = MAP_APPFONT ( 40 , 14 ) ;
Text [ en-US ] = "Close" ; Text [ en-US ] = "Cancel" ;
TabStop = TRUE ; TabStop = TRUE ;
}; };
PushButton BTN_SELECT PushButton BTN_SELECT
{ {
Pos = MAP_APPFONT ( 108 , 200 ) ; Pos = MAP_APPFONT ( 128 , 200 ) ;
Size = MAP_APPFONT ( 50 , 14 ) ; Size = MAP_APPFONT ( 90 , 14 ) ;
Text [ en-US ] = "Close" ; Text [ en-US ] = "Select Range" ;
TabStop = TRUE ; TabStop = TRUE ;
}; };
...@@ -191,10 +191,9 @@ ModelessDialog RID_SCDLG_NAMES ...@@ -191,10 +191,9 @@ ModelessDialog RID_SCDLG_NAMES
Text [ en-US ] = "Document (Global)" ; Text [ en-US ] = "Document (Global)" ;
}; };
FixedText FT_INFO_LINE FixedText FT_INFO
{ {
Border = TRUE; Pos = MAP_APPFONT( 6, 127 );
Pos = MAP_APPFONT( 6, 130 );
Size = MAP_APPFONT( 210, 14 ); Size = MAP_APPFONT( 210, 14 );
TabStop = FALSE; TabStop = FALSE;
}; };
...@@ -218,4 +217,16 @@ ModelessDialog RID_SCDLG_NAMES ...@@ -218,4 +217,16 @@ ModelessDialog RID_SCDLG_NAMES
{ {
Text [en-US] = "Scope"; Text [en-US] = "Scope";
}; };
String STR_ERR_NAME_EXISTS
{
Text [ en-US ] = "Invalid name. Already in use for the selected scope.";
};
String STR_ERR_NAME_INVALID
{
Text [ en-US ] = "Invalid name. Only use letters, numbers and underscore and don't use names like cell addresses";
};
String STR_DEFAULT_INFO
{
Text [en-US] = "Select cells in the document to update the range.";
};
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment