sc/inc/globstr.hrc | 4 +++- sc/inc/rangenam.hxx | 10 +++++++++- sc/source/core/tool/rangenam.cxx | 12 ++++++------ sc/source/ui/app/inputwin.cxx | 2 +- sc/source/ui/dbgui/dbnamdlg.cxx | 2 +- sc/source/ui/inc/namedefdlg.hxx | 1 + sc/source/ui/namedlg/namedefdlg.cxx | 13 +++++++++++-- sc/source/ui/namedlg/namedlg.cxx | 2 +- sc/source/ui/src/globstr.src | 4 ++++ sc/source/ui/vba/vbanames.cxx | 4 ++-- sc/uiconfig/scalc/ui/definename.ui | 2 +- 11 files changed, 40 insertions(+), 16 deletions(-)
New commits: commit 413232229cbfd9d49ce9d1cdbb6b6e2dbe83af38 Author: Abhilash Singh <abhilash300si...@gmail.com> Date: Sun Jan 22 14:42:15 2017 +0530 tdf#86214 User isn't warned entering a cell address not allowed Refactored ScRangeData::IsNameValid Change-Id: I74dd5830d13e48e8fe9a5180a819be4acdc9a1db Reviewed-on: https://gerrit.libreoffice.org/33386 Reviewed-by: Eike Rathke <er...@redhat.com> Tested-by: Jenkins <c...@libreoffice.org> diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc index 68d48d9..3b3cef6 100644 --- a/sc/inc/globstr.hrc +++ b/sc/inc/globstr.hrc @@ -712,7 +712,9 @@ #define STR_QUERY_PIVOTTABLE_DELTAB 545 -#define SC_GLOBSTR_STR_COUNT 546 /**< the count of permanently resident strings */ +#define STR_ERR_NAME_INVALID_CELL_REF 546 + +#define SC_GLOBSTR_STR_COUNT 547 /**< the count of permanently resident strings */ #endif diff --git a/sc/inc/rangenam.hxx b/sc/inc/rangenam.hxx index 19c288b..737c5e6 100644 --- a/sc/inc/rangenam.hxx +++ b/sc/inc/rangenam.hxx @@ -59,6 +59,13 @@ public: AbsPos = 0x0080 }; + enum IsNameValidType + { + NAME_VALID, + NAME_INVALID_CELL_REF, + NAME_INVALID_BAD_STRING + }; + private: OUString aName; OUString aUpperName; // #i62977# for faster searching (aName is never modified after ctor) @@ -154,7 +161,8 @@ public: void ValidateTabRefs(); static void MakeValidName( OUString& rName ); - SC_DLLPUBLIC static bool IsNameValid( const OUString& rName, ScDocument* pDoc ); + + SC_DLLPUBLIC static IsNameValidType IsNameValid( const OUString& rName, ScDocument* pDoc ); SCROW GetMaxRow() const; SCCOL GetMaxCol() const; diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx index d7fba04..1728460 100644 --- a/sc/source/core/tool/rangenam.cxx +++ b/sc/source/core/tool/rangenam.cxx @@ -474,21 +474,21 @@ void ScRangeData::MakeValidName( OUString& rName ) } } -bool ScRangeData::IsNameValid( const OUString& rName, ScDocument* pDoc ) +ScRangeData::IsNameValidType ScRangeData::IsNameValid( const OUString& rName, ScDocument* pDoc ) { /* XXX If changed, sc/source/filter/ftools/ftools.cxx * ScfTools::ConvertToScDefinedName needs to be changed too. */ sal_Char a('.'); if (rName.indexOf(a) != -1) - return false; + return NAME_INVALID_BAD_STRING; sal_Int32 nPos = 0; sal_Int32 nLen = rName.getLength(); if ( !nLen || !ScCompiler::IsCharFlagAllConventions( rName, nPos++, ScCharFlags::CharName ) ) - return false; + return NAME_INVALID_BAD_STRING; while ( nPos < nLen ) { if ( !ScCompiler::IsCharFlagAllConventions( rName, nPos++, ScCharFlags::Name ) ) - return false; + return NAME_INVALID_BAD_STRING; } ScAddress aAddr; ScRange aRange; @@ -500,10 +500,10 @@ bool ScRangeData::IsNameValid( const OUString& rName, ScDocument* pDoc ) if (aRange.Parse(rName, pDoc, details) != ScRefFlags::ZERO || aAddr.Parse(rName, pDoc, details) != ScRefFlags::ZERO ) { - return false; + return NAME_INVALID_CELL_REF; } } - return true; + return NAME_VALID; } SCROW ScRangeData::GetMaxRow() const diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx index 9239398..9f94098 100644 --- a/sc/source/ui/app/inputwin.cxx +++ b/sc/source/ui/app/inputwin.cxx @@ -1991,7 +1991,7 @@ static ScNameInputType lcl_GetInputType( const OUString& rText ) eRet = SC_NAME_INPUT_ROW; else if ( pDoc->GetTable( rText, nNameTab ) ) eRet = SC_NAME_INPUT_SHEET; - else if ( ScRangeData::IsNameValid( rText, pDoc ) ) // nothing found, create new range? + else if ( ScRangeData::IsNameValid( rText, pDoc ) == ScRangeData::NAME_VALID ) // nothing found, create new range? { if ( rViewData.GetSimpleArea( aRange ) == SC_MARK_SIMPLE ) eRet = SC_NAME_INPUT_DEFINE; diff --git a/sc/source/ui/dbgui/dbnamdlg.cxx b/sc/source/ui/dbgui/dbnamdlg.cxx index 8c91758..4596729 100644 --- a/sc/source/ui/dbgui/dbnamdlg.cxx +++ b/sc/source/ui/dbgui/dbnamdlg.cxx @@ -416,7 +416,7 @@ IMPL_LINK_NOARG(ScDbNameDlg, AddBtnHdl, Button*, void) if ( !aNewName.isEmpty() && !aNewArea.isEmpty() ) { - if ( ScRangeData::IsNameValid( aNewName, pDoc ) && aNewName != STR_DB_LOCAL_NONAME ) + if ( ScRangeData::IsNameValid( aNewName, pDoc ) == ScRangeData::NAME_VALID && aNewName != STR_DB_LOCAL_NONAME ) { // weil jetzt editiert werden kann, muss erst geparst werden ScRange aTmpRange; diff --git a/sc/source/ui/inc/namedefdlg.hxx b/sc/source/ui/inc/namedefdlg.hxx index 3a036a9..447a762 100644 --- a/sc/source/ui/inc/namedefdlg.hxx +++ b/sc/source/ui/inc/namedefdlg.hxx @@ -50,6 +50,7 @@ private: OUString maStrInfoDefault; const OUString maGlobalNameStr; const OUString maErrInvalidNameStr; + const OUString maErrInvalidNameCellRefStr; const OUString maErrNameInUse; //hack to call this dialog from Manage Names diff --git a/sc/source/ui/namedlg/namedefdlg.cxx b/sc/source/ui/namedlg/namedefdlg.cxx index aa96427..23a3c1a 100644 --- a/sc/source/ui/namedlg/namedefdlg.cxx +++ b/sc/source/ui/namedlg/namedefdlg.cxx @@ -36,6 +36,7 @@ ScNameDefDlg::ScNameDefDlg( SfxBindings* pB, SfxChildWindow* pCW, vcl::Window* p maGlobalNameStr ( ScGlobal::GetRscString(STR_GLOBAL_SCOPE) ), maErrInvalidNameStr( ScGlobal::GetRscString(STR_ERR_NAME_INVALID)), + maErrInvalidNameCellRefStr( ScGlobal::GetRscString(STR_ERR_NAME_INVALID_CELL_REF)), maErrNameInUse ( ScGlobal::GetRscString(STR_ERR_NAME_EXISTS)), maRangeMap( aRangeMap ) { @@ -150,6 +151,7 @@ bool ScNameDefDlg::IsNameValid() pRangeName = maRangeMap.find(aScope)->second; } + ScRangeData::IsNameValidType eType; m_pFtInfo->SetControlBackground(GetSettings().GetStyleSettings().GetDialogColor()); if ( aName.isEmpty() ) { @@ -157,10 +159,17 @@ bool ScNameDefDlg::IsNameValid() m_pFtInfo->SetText(maStrInfoDefault); return false; } - else if (!ScRangeData::IsNameValid( aName, mpDoc )) + else if ((eType = ScRangeData::IsNameValid( aName, mpDoc )) != ScRangeData::NAME_VALID) { m_pFtInfo->SetControlBackground(GetSettings().GetStyleSettings().GetHighlightColor()); - m_pFtInfo->SetText(maErrInvalidNameStr); + if (eType == ScRangeData::NAME_INVALID_BAD_STRING) + { + m_pFtInfo->SetText(maErrInvalidNameStr); + } + else if (eType == ScRangeData::NAME_INVALID_CELL_REF) + { + m_pFtInfo->SetText(maErrInvalidNameCellRefStr); + } m_pBtnAdd->Disable(); return false; } diff --git a/sc/source/ui/namedlg/namedlg.cxx b/sc/source/ui/namedlg/namedlg.cxx index 5a7a8f9..abf1f57 100644 --- a/sc/source/ui/namedlg/namedlg.cxx +++ b/sc/source/ui/namedlg/namedlg.cxx @@ -278,7 +278,7 @@ bool ScNameDlg::IsNameValid() ScRangeName* pRangeName = GetRangeName( aScope ); - if (!ScRangeData::IsNameValid( aName, mpDoc )) + if (ScRangeData::IsNameValid( aName, mpDoc ) != ScRangeData::NAME_VALID) { m_pFtInfo->SetControlBackground(GetSettings().GetStyleSettings().GetHighlightColor()); m_pFtInfo->SetText(maErrInvalidNameStr); diff --git a/sc/source/ui/src/globstr.src b/sc/source/ui/src/globstr.src index b11808f..dbbd3e4 100644 --- a/sc/source/ui/src/globstr.src +++ b/sc/source/ui/src/globstr.src @@ -2113,6 +2113,10 @@ Resource RID_GLOBSTR { Text [ en-US ] = "The selected sheet(s) contain source data of related pivot tables that will be lost. Are you sure you want to delete the selected sheet(s)?"; }; + String STR_ERR_NAME_INVALID_CELL_REF + { + Text [ en-US ] = "Invalid name. Reference to a cell, or a range of cells not allowed."; + }; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/vba/vbanames.cxx b/sc/source/ui/vba/vbanames.cxx index f9f1e32..c366521 100644 --- a/sc/source/ui/vba/vbanames.cxx +++ b/sc/source/ui/vba/vbanames.cxx @@ -101,7 +101,7 @@ ScVbaNames::Add( const css::uno::Any& Name , NameLocal >>= sName; if ( !sName.isEmpty() ) { - if ( !ScRangeData::IsNameValid( sName , getScDocument() ) ) + if ( ScRangeData::IsNameValid( sName , getScDocument() ) != ScRangeData::NAME_VALID ) { OUString sResult ; sal_Int32 nToken = 0; @@ -112,7 +112,7 @@ ScVbaNames::Add( const css::uno::Any& Name , else sResult = sName.copy( nIndex ); sName = sResult ; - if ( !ScRangeData::IsNameValid( sName , getScDocument() ) ) + if ( ScRangeData::IsNameValid( sName , getScDocument() ) != ScRangeData::NAME_VALID ) throw uno::RuntimeException( "This Name is not valid ." ); } } diff --git a/sc/uiconfig/scalc/ui/definename.ui b/sc/uiconfig/scalc/ui/definename.ui index 25e9bf2..01a6a69 100644 --- a/sc/uiconfig/scalc/ui/definename.ui +++ b/sc/uiconfig/scalc/ui/definename.ui @@ -145,7 +145,7 @@ <property name="can_focus">True</property> <property name="hexpand">True</property> <property name="invisible_char">â¢</property> - <property name="width_chars">42</property> + <property name="width_chars">50</property> </object> <packing> <property name="expand">False</property>
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits