summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGulsah Kose <gulsah.1004@gmail.com>2018-01-16 01:30:04 +0300
committerGülşah Köse <gulsah.1004@gmail.com>2018-01-25 12:05:00 +0100
commita626e249033fb9a7ac117e28f3152cedf98b61fc (patch)
tree6d4fa2a5e6b4044fcdbbd323c93c428934b151e6
parentec4de8ff110d6064303f4a1027e4d55c29c4db54 (diff)
[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: Gulsah Kose <gulsah.1004@gmail.com> Reviewed-on: https://gerrit.libreoffice.org/47925 Tested-by: Jenkins <ci@libreoffice.org>
-rw-r--r--officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu5
-rw-r--r--sc/inc/document.hxx7
-rw-r--r--sc/inc/sc.hrc3
-rw-r--r--sc/sdi/cellsh.sdi1
-rw-r--r--sc/sdi/scalc.sdi18
-rw-r--r--sc/source/core/data/documen3.cxx26
-rw-r--r--sc/source/ui/view/cellsh.cxx13
-rw-r--r--sc/source/ui/view/cellsh1.cxx1
-rw-r--r--sc/uiconfig/scalc/popupmenu/cell.xml1
9 files changed, 74 insertions, 1 deletions
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
index f87cc3f47f35..979f4a176698 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
@@ -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>
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index c1c628fb451f..10b2bd45213f 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -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
diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc
index b20f0680711f..5c75ae6c8c45 100644
--- a/sc/inc/sc.hrc
+++ b/sc/inc/sc.hrc
@@ -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)
diff --git a/sc/sdi/cellsh.sdi b/sc/sdi/cellsh.sdi
index b21769d8d258..4fc0a44f1da0 100644
--- a/sc/sdi/cellsh.sdi
+++ b/sc/sdi/cellsh.sdi
@@ -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; ]
diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi
index 956bacaae8e3..0925e0483865 100644
--- a/sc/sdi/scalc.sdi
+++ b/sc/sdi/scalc.sdi
@@ -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
()
[
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index a018a065b1d2..f7f8687ca4b2 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -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();
diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx
index 7157d112f766..cae223dd5cde 100644
--- a/sc/source/ui/view/cellsh.cxx
+++ b/sc/source/ui/view/cellsh.cxx
@@ -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() ) )
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 4f075c981999..9a1e7dc8a3cf 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -1883,6 +1883,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
break;
case FID_DEFINE_NAME:
+ case FID_DEFINE_CURRENT_NAME:
if ( pReqArgs )
{
const SfxPoolItem* pItem;
diff --git a/sc/uiconfig/scalc/popupmenu/cell.xml b/sc/uiconfig/scalc/popupmenu/cell.xml
index fada79e703ce..17e9a67994ab 100644
--- a/sc/uiconfig/scalc/popupmenu/cell.xml
+++ b/sc/uiconfig/scalc/popupmenu/cell.xml
@@ -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>