Kaydet (Commit) a626e249 authored tarafından Gulsah Kose's avatar Gulsah Kose Kaydeden (comit) Gülşah Köse

[Pardus] tdf#108989 Add contextual manage names command.

If cursor in a named range .uno:DefineCurrentName command
appears on context menu. Opens manage names dialog.

This patch is sponsored by ULAKBIM/Pardus project.

Change-Id: I730fd427fa3d6f5c92563282ff8ca3c0e668eddd
Signed-off-by: 's avatarGulsah Kose <gulsah.1004@gmail.com>
Reviewed-on: https://gerrit.libreoffice.org/47925Tested-by: 's avatarJenkins <ci@libreoffice.org>
üst ec4de8ff
......@@ -1289,6 +1289,11 @@
<value>1</value>
</prop>
</node>
<node oor:name=".uno:DefineCurrentName" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">~Manage Names...</value>
</prop>
</node>
<node oor:name=".uno:InsertName" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">~Insert Named Range or Expression...</value>
......
......@@ -252,6 +252,12 @@ enum CommentCaptionState
MIXED // There are comments in shown and hidden.
};
enum RangeNameScope
{
GLOBAL, // A range name can be defined
SHEET // with two scope on Manage Names dialog.
};
struct ScDocStat
{
OUString aDocName;
......@@ -606,6 +612,7 @@ public:
SC_DLLPUBLIC ScRangeName* GetRangeName() const;
void SetRangeName(SCTAB nTab, ScRangeName* pNew);
void SetRangeName( ScRangeName* pNewRangeName );
bool IsAddressInRangeName( RangeNameScope eScope, ScAddress& rAddress);
/** Find a named expression / range name in either global or a local scope.
@param nTab
......
......@@ -301,7 +301,8 @@
#define FID_INS_COLUMNS_AFTER (INSERT_MENU_START + 21)
#define FID_INS_ROWS_BEFORE (INSERT_MENU_START + 22)
#define FID_INS_COLUMNS_BEFORE (INSERT_MENU_START + 23)
#define INSERT_MENU_END (INSERT_MENU_START + 24)
#define FID_DEFINE_CURRENT_NAME (INSERT_MENU_START + 24)
#define INSERT_MENU_END (INSERT_MENU_START + 25)
#define FORMAT_MENU_START (INSERT_MENU_END)
#define FID_CELL_FORMAT (FORMAT_MENU_START)
......
......@@ -21,6 +21,7 @@ interface CellSelection
{
// slots which are disabled in the DrawShell {
FID_DEFINE_NAME [ ExecMethod = ExecuteEdit; StateMethod = GetState; ]
FID_DEFINE_CURRENT_NAME [ ExecMethod = ExecuteEdit; StateMethod = GetState; ]
FID_ADD_NAME [ ExecMethod = ExecuteEdit; StateMethod = GetState; ]
SID_DEFINE_COLROWNAMERANGES [ ExecMethod = ExecuteEdit; StateMethod = GetState; ]
SID_OPENDLG_SOLVE [ ExecMethod = Execute; StateMethod = GetState; ]
......
......@@ -1184,6 +1184,24 @@ SfxVoidItem DefineName FID_DEFINE_NAME
]
SfxVoidItem DefineCurrentName FID_DEFINE_CURRENT_NAME
(SfxStringItem Name FID_DEFINE_CURRENT_NAME,SfxStringItem Symbol FN_PARAM_1,SfxStringItem Options FN_PARAM_2)
[
AutoUpdate = FALSE,
FastCall = FALSE,
ReadOnlyDoc = TRUE,
Toggle = FALSE,
Container = FALSE,
RecordAbsolute = FALSE,
RecordPerSet;
AccelConfig = TRUE,
MenuConfig = TRUE,
ToolBoxConfig = TRUE,
GroupId = SfxGroupId::Insert;
]
SfxVoidItem DefinePrintArea SID_DEFINE_PRINTAREA
()
[
......
......@@ -208,6 +208,32 @@ void ScDocument::SetRangeName( ScRangeName* pNewRangeName )
pRangeName = pNewRangeName;
}
bool ScDocument::IsAddressInRangeName( RangeNameScope eScope, ScAddress& rAddress )
{
ScRangeName* pRangeNames;
ScRange aNameRange;
bool bRet = false;
if (eScope == RangeNameScope::GLOBAL)
pRangeNames= GetRangeName();
else
pRangeNames= GetRangeName(rAddress.Tab());
ScRangeName::iterator itrBegin = pRangeNames->begin(), itrEnd = pRangeNames->end();
for (ScRangeName::iterator itr = itrBegin; itr != itrEnd; ++itr)
{
itr->second->IsValidReference(aNameRange);
bRet = aNameRange.In(rAddress);
if (!bRet)
continue;
else
break;
}
return bRet;
}
bool ScDocument::InsertNewRangeName( const OUString& rName, const ScAddress& rPos, const OUString& rExpr )
{
ScRangeName* pGlobalNames = GetRangeName();
......
......@@ -1185,6 +1185,19 @@ void ScCellShell::GetState(SfxItemSet &rSet)
}
break;
case FID_DEFINE_CURRENT_NAME:
{
ScAddress aCurrentAddress = ScAddress( nPosX, nPosY, nTab );
if ( pDoc &&
!pDoc->IsAddressInRangeName( RangeNameScope::GLOBAL, aCurrentAddress ) &&
!pDoc->IsAddressInRangeName( RangeNameScope::SHEET, aCurrentAddress ))
{
rSet.DisableItem( nWhich );
}
}
break;
case SID_SPELL_DIALOG:
{
if ( pDoc && pData && pDoc->IsTabProtected( pData->GetTabNo() ) )
......
......@@ -1883,6 +1883,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
break;
case FID_DEFINE_NAME:
case FID_DEFINE_CURRENT_NAME:
if ( pReqArgs )
{
const SfxPoolItem* pItem;
......
......@@ -40,4 +40,5 @@
<menu:menuseparator/>
<menu:menuitem menu:id=".uno:DataSelect"/>
<menu:menuitem menu:id=".uno:CurrentValidation"/>
<menu:menuitem menu:id=".uno:DefineCurrentName"/>
</menu:menupopup>
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