summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-05-02 15:30:20 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-05-02 15:43:46 -0400
commit56cce6fd8151a916e1be540ac18724b46d1b15fc (patch)
tree18eddb22ce667f8a999d96339b10577cf7c21084
parentdd9c9a69da7b22c4166391df082ac23878312a01 (diff)
Implement "fill single edit" mode and map it to Ctrl-' by default.
Excel does this apparently, and lots of people want it. Change-Id: Ia741ebb84526197d28caa323d36709e38b8f1323
-rw-r--r--officecfg/registry/data/org/openoffice/Office/Accelerators.xcu6
-rw-r--r--officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu8
-rw-r--r--sc/inc/sc.hrc1
-rw-r--r--sc/inc/scmod.hxx2
-rw-r--r--sc/sdi/cellsh.sdi1
-rw-r--r--sc/sdi/scalc.sdi25
-rw-r--r--sc/source/ui/app/inputhdl.cxx8
-rw-r--r--sc/source/ui/app/scmod.cxx4
-rw-r--r--sc/source/ui/inc/cellsh.hxx2
-rw-r--r--sc/source/ui/inc/inputhdl.hxx2
-rw-r--r--sc/source/ui/view/cellsh.cxx4
-rw-r--r--sc/source/ui/view/cellsh1.cxx37
12 files changed, 94 insertions, 6 deletions
diff --git a/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu b/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu
index 624bcdf1e9a6..ef0ec1b539b0 100644
--- a/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu
@@ -967,6 +967,12 @@
<value xml:lang="en-US">.uno:ToggleFormula</value>
</prop>
</node>
+ <node oor:name="QUOTERIGHT_MOD1" oor:op="replace">
+ <prop oor:name="Command">
+ <value xml:lang="x-no-translate">I10N SHORTCUTS - NO TRANSLATE</value>
+ <value xml:lang="en-US">.uno:FillSingleEdit</value>
+ </prop>
+ </node>
<node oor:name="Y_SHIFT_MOD1" oor:op="replace">
<prop oor:name="Command">
<value xml:lang="x-no-translate">I10N SHORTCUTS - NO TRANSLATE</value>
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
index 18dc5d3fc4f5..1bfa929af358 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
@@ -632,6 +632,14 @@
<value xml:lang="en-US">~Left</value>
</prop>
</node>
+ <node oor:name=".uno:FillSingleEdit" oor:op="replace">
+ <prop oor:name="Label" oor:type="xs:string">
+ <value xml:lang="en-US">Fill Single ~Edit</value>
+ </prop>
+ <prop oor:name="ContextLabel" oor:type="xs:string">
+ <value xml:lang="en-US">Single ~Edit</value>
+ </prop>
+ </node>
<node oor:name=".uno:FillTable" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Fill ~Sheets...</value>
diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc
index 757931f7914f..43bda66ddcb8 100644
--- a/sc/inc/sc.hrc
+++ b/sc/inc/sc.hrc
@@ -286,6 +286,7 @@
#define FID_FILL_TO_LEFT (EDIT_MENU_START + 7)
#define FID_FILL_TAB (EDIT_MENU_START + 8)
#define FID_FILL_SERIES (EDIT_MENU_START + 9)
+#define FID_FILL_SINGLE_EDIT (EDIT_MENU_START + 10)
#define SID_SC_EDIT_OBJECT (EDIT_MENU_START + 14)
#define SID_HFEDIT (EDIT_MENU_START + 15)
diff --git a/sc/inc/scmod.hxx b/sc/inc/scmod.hxx
index de9d9c2372ed..cafefdf5d836 100644
--- a/sc/inc/scmod.hxx
+++ b/sc/inc/scmod.hxx
@@ -205,7 +205,7 @@ SC_DLLPUBLIC void SetAppOptions ( const ScAppOptions& rO
// InputHandler:
bool IsEditMode(); // not for SC_INPUT_TYPE
bool IsInputMode(); // also for SC_INPUT_TYPE
- void SetInputMode( ScInputMode eMode );
+ void SetInputMode( ScInputMode eMode, const OUString* pInitText = NULL );
bool InputKeyEvent( const KeyEvent& rKEvt, bool bStartEdit = false );
SC_DLLPUBLIC void InputEnterHandler( sal_uInt8 nBlockMode = 0 );
void InputCancelHandler();
diff --git a/sc/sdi/cellsh.sdi b/sc/sdi/cellsh.sdi
index b77b4f88cca8..62ce4858c957 100644
--- a/sc/sdi/cellsh.sdi
+++ b/sc/sdi/cellsh.sdi
@@ -150,6 +150,7 @@ interface CellSelection
FID_FILL_TAB [ ExecMethod = ExecuteEdit; StateMethod = GetState; ]
FID_FILL_SERIES [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
FID_FILL_AUTO [ ExecMethod = ExecuteEdit; StateMethod = GetState; ]
+ FID_FILL_SINGLE_EDIT [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
SID_RANDOM_NUMBER_GENERATOR_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
SID_SAMPLING_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
SID_DESCRIPTIVE_STATISTICS_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi
index d260cdae945b..fe3d780e7ccc 100644
--- a/sc/sdi/scalc.sdi
+++ b/sc/sdi/scalc.sdi
@@ -2414,6 +2414,31 @@ SfxVoidItem FillLeft FID_FILL_TO_LEFT
]
+SfxVoidItem FillSingleEdit FID_FILL_SINGLE_EDIT
+()
+[
+ /* flags: */
+ AutoUpdate = FALSE,
+ Cachable = Cachable,
+ FastCall = FALSE,
+ HasCoreId = FALSE,
+ HasDialog = TRUE,
+ ReadOnlyDoc = TRUE,
+ Toggle = FALSE,
+ Container = FALSE,
+ RecordAbsolute = FALSE,
+ RecordPerSet;
+ Asynchron;
+
+ /* config: */
+ AccelConfig = TRUE,
+ MenuConfig = TRUE,
+ StatusBarConfig = FALSE,
+ ToolBoxConfig = TRUE,
+ GroupId = GID_EDIT;
+]
+
+
SfxVoidItem FillModeEnd SID_FILL_NONE
()
[
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 78481fa0ab73..f1a3da8a254b 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -2381,7 +2381,7 @@ void ScInputHandler::InvalidateAttribs()
// --------------- public Methoden --------------------------------------------
-void ScInputHandler::SetMode( ScInputMode eNewMode )
+void ScInputHandler::SetMode( ScInputMode eNewMode, const OUString* pInitText )
{
if ( eMode == eNewMode )
return;
@@ -2419,6 +2419,12 @@ void ScInputHandler::SetMode( ScInputMode eNewMode )
}
}
+ if (pInitText)
+ {
+ pEngine->SetText(*pInitText);
+ bModified = true;
+ }
+
sal_Int32 nPara = pEngine->GetParagraphCount()-1;
sal_Int32 nLen = pEngine->GetText(nPara).getLength();
sal_uInt16 nCount = pEngine->GetViewCount();
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index ec2ce296e670..586686de142c 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -1427,11 +1427,11 @@ void ScModule::ViewShellChanged()
pShell->UpdateInputHandler();
}
-void ScModule::SetInputMode( ScInputMode eMode )
+void ScModule::SetInputMode( ScInputMode eMode, const OUString* pInitText )
{
ScInputHandler* pHdl = GetInputHdl();
if (pHdl)
- pHdl->SetMode( eMode );
+ pHdl->SetMode(eMode, pInitText);
}
bool ScModule::IsEditMode()
diff --git a/sc/source/ui/inc/cellsh.hxx b/sc/source/ui/inc/cellsh.hxx
index fa83707c6315..2318cf86acc5 100644
--- a/sc/source/ui/inc/cellsh.hxx
+++ b/sc/source/ui/inc/cellsh.hxx
@@ -61,6 +61,8 @@ private:
void ExecuteXMLSourceDialog();
void ExecuteSubtotals(SfxRequest& rReq);
+ void ExecuteFillSingleEdit();
+
DECL_LINK( ClipboardChanged, TransferableDataHelper* );
DECL_LINK( DialogClosed, void* );
diff --git a/sc/source/ui/inc/inputhdl.hxx b/sc/source/ui/inc/inputhdl.hxx
index 231e9ad81bce..937313832e1a 100644
--- a/sc/source/ui/inc/inputhdl.hxx
+++ b/sc/source/ui/inc/inputhdl.hxx
@@ -164,7 +164,7 @@ public:
ScInputHandler();
virtual ~ScInputHandler();
- void SetMode( ScInputMode eNewMode );
+ void SetMode( ScInputMode eNewMode, const OUString* pInitText = NULL );
bool IsInputMode() const { return (eMode != SC_INPUT_NONE); }
bool IsEditMode() const { return (eMode != SC_INPUT_NONE &&
eMode != SC_INPUT_TYPE); }
diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx
index 498d17387541..2a5aa5b17230 100644
--- a/sc/source/ui/view/cellsh.cxx
+++ b/sc/source/ui/view/cellsh.cxx
@@ -199,7 +199,9 @@ void ScCellShell::GetBlockState( SfxItemSet& rSet )
nCol2, nRow1, nCol2, nRow2, rMark ); // last column
}
break;
-
+ case FID_FILL_SINGLE_EDIT:
+ bDisable = false;
+ break;
case SID_CUT: // cut
case FID_INS_CELL: // insert cells, just simple selection
bDisable = (!bSimpleArea);
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 858d1abb30e9..e53be77d85b9 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -79,6 +79,10 @@
#include "scui_def.hxx"
#include <svx/dialogs.hrc>
#include "scabstdlg.hxx"
+#include <tokenstringcontext.hxx>
+#include <cellvalue.hxx>
+#include <tokenarray.hxx>
+#include <formulacell.hxx>
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
@@ -901,6 +905,9 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
}
}
break;
+ case FID_FILL_SINGLE_EDIT:
+ ExecuteFillSingleEdit();
+ break;
case SID_RANDOM_NUMBER_GENERATOR_DIALOG:
{
sal_uInt16 nId = ScRandomNumberGeneratorDialogWrapper::GetChildWindowId();
@@ -2771,6 +2778,36 @@ void ScCellShell::ExecuteSubtotals(SfxRequest& rReq)
delete pDlg;
}
+void ScCellShell::ExecuteFillSingleEdit()
+{
+ ScAddress aCurPos = GetViewData()->GetCurPos();
+
+ OUString aInit;
+
+ if (aCurPos.Row() > 0)
+ {
+ // Get the initial text value from the above cell.
+
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScRefCellValue aCell;
+ ScAddress aPrevPos = aCurPos;
+ aPrevPos.IncRow(-1);
+ aCell.assign(*pDoc, aPrevPos);
+
+ if (aCell.meType == CELLTYPE_FORMULA)
+ {
+ aInit = "=";
+ const ScTokenArray* pCode = aCell.mpFormula->GetCode();
+ sc::TokenStringContext aCxt(pDoc, pDoc->GetGrammar());
+ aInit += pCode->CreateString(aCxt, aCurPos);
+ }
+ else
+ aInit = aCell.getString(pDoc);
+ }
+
+ SC_MOD()->SetInputMode(SC_INPUT_TABLE, &aInit);
+}
+
IMPL_LINK_NOARG(ScCellShell, DialogClosed)
{
OSL_ENSURE( pImpl->m_pLinkedDlg, "ScCellShell::DialogClosed(): invalid request" );