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
This commit is contained in:
Kohei Yoshida
2014-05-02 15:30:20 -04:00
parent dd9c9a69da
commit 56cce6fd81
12 changed files with 94 additions and 6 deletions

View File

@@ -967,6 +967,12 @@
<value xml:lang="en-US">.uno:ToggleFormula</value> <value xml:lang="en-US">.uno:ToggleFormula</value>
</prop> </prop>
</node> </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"> <node oor:name="Y_SHIFT_MOD1" oor:op="replace">
<prop oor:name="Command"> <prop oor:name="Command">
<value xml:lang="x-no-translate">I10N SHORTCUTS - NO TRANSLATE</value> <value xml:lang="x-no-translate">I10N SHORTCUTS - NO TRANSLATE</value>

View File

@@ -632,6 +632,14 @@
<value xml:lang="en-US">~Left</value> <value xml:lang="en-US">~Left</value>
</prop> </prop>
</node> </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"> <node oor:name=".uno:FillTable" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string"> <prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Fill ~Sheets...</value> <value xml:lang="en-US">Fill ~Sheets...</value>

View File

@@ -286,6 +286,7 @@
#define FID_FILL_TO_LEFT (EDIT_MENU_START + 7) #define FID_FILL_TO_LEFT (EDIT_MENU_START + 7)
#define FID_FILL_TAB (EDIT_MENU_START + 8) #define FID_FILL_TAB (EDIT_MENU_START + 8)
#define FID_FILL_SERIES (EDIT_MENU_START + 9) #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_SC_EDIT_OBJECT (EDIT_MENU_START + 14)
#define SID_HFEDIT (EDIT_MENU_START + 15) #define SID_HFEDIT (EDIT_MENU_START + 15)

View File

@@ -205,7 +205,7 @@ SC_DLLPUBLIC void SetAppOptions ( const ScAppOptions& rO
// InputHandler: // InputHandler:
bool IsEditMode(); // not for SC_INPUT_TYPE bool IsEditMode(); // not for SC_INPUT_TYPE
bool IsInputMode(); // also 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 ); bool InputKeyEvent( const KeyEvent& rKEvt, bool bStartEdit = false );
SC_DLLPUBLIC void InputEnterHandler( sal_uInt8 nBlockMode = 0 ); SC_DLLPUBLIC void InputEnterHandler( sal_uInt8 nBlockMode = 0 );
void InputCancelHandler(); void InputCancelHandler();

View File

@@ -150,6 +150,7 @@ interface CellSelection
FID_FILL_TAB [ ExecMethod = ExecuteEdit; StateMethod = GetState; ] FID_FILL_TAB [ ExecMethod = ExecuteEdit; StateMethod = GetState; ]
FID_FILL_SERIES [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ] FID_FILL_SERIES [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
FID_FILL_AUTO [ ExecMethod = ExecuteEdit; StateMethod = GetState; ] 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_RANDOM_NUMBER_GENERATOR_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
SID_SAMPLING_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ] SID_SAMPLING_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
SID_DESCRIPTIVE_STATISTICS_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ] SID_DESCRIPTIVE_STATISTICS_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]

View File

@@ -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 SfxVoidItem FillModeEnd SID_FILL_NONE
() ()
[ [

View File

@@ -2381,7 +2381,7 @@ void ScInputHandler::InvalidateAttribs()
// --------------- public Methoden -------------------------------------------- // --------------- public Methoden --------------------------------------------
void ScInputHandler::SetMode( ScInputMode eNewMode ) void ScInputHandler::SetMode( ScInputMode eNewMode, const OUString* pInitText )
{ {
if ( eMode == eNewMode ) if ( eMode == eNewMode )
return; 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 nPara = pEngine->GetParagraphCount()-1;
sal_Int32 nLen = pEngine->GetText(nPara).getLength(); sal_Int32 nLen = pEngine->GetText(nPara).getLength();
sal_uInt16 nCount = pEngine->GetViewCount(); sal_uInt16 nCount = pEngine->GetViewCount();

View File

@@ -1427,11 +1427,11 @@ void ScModule::ViewShellChanged()
pShell->UpdateInputHandler(); pShell->UpdateInputHandler();
} }
void ScModule::SetInputMode( ScInputMode eMode ) void ScModule::SetInputMode( ScInputMode eMode, const OUString* pInitText )
{ {
ScInputHandler* pHdl = GetInputHdl(); ScInputHandler* pHdl = GetInputHdl();
if (pHdl) if (pHdl)
pHdl->SetMode( eMode ); pHdl->SetMode(eMode, pInitText);
} }
bool ScModule::IsEditMode() bool ScModule::IsEditMode()

View File

@@ -61,6 +61,8 @@ private:
void ExecuteXMLSourceDialog(); void ExecuteXMLSourceDialog();
void ExecuteSubtotals(SfxRequest& rReq); void ExecuteSubtotals(SfxRequest& rReq);
void ExecuteFillSingleEdit();
DECL_LINK( ClipboardChanged, TransferableDataHelper* ); DECL_LINK( ClipboardChanged, TransferableDataHelper* );
DECL_LINK( DialogClosed, void* ); DECL_LINK( DialogClosed, void* );

View File

@@ -164,7 +164,7 @@ public:
ScInputHandler(); ScInputHandler();
virtual ~ScInputHandler(); virtual ~ScInputHandler();
void SetMode( ScInputMode eNewMode ); void SetMode( ScInputMode eNewMode, const OUString* pInitText = NULL );
bool IsInputMode() const { return (eMode != SC_INPUT_NONE); } bool IsInputMode() const { return (eMode != SC_INPUT_NONE); }
bool IsEditMode() const { return (eMode != SC_INPUT_NONE && bool IsEditMode() const { return (eMode != SC_INPUT_NONE &&
eMode != SC_INPUT_TYPE); } eMode != SC_INPUT_TYPE); }

View File

@@ -199,7 +199,9 @@ void ScCellShell::GetBlockState( SfxItemSet& rSet )
nCol2, nRow1, nCol2, nRow2, rMark ); // last column nCol2, nRow1, nCol2, nRow2, rMark ); // last column
} }
break; break;
case FID_FILL_SINGLE_EDIT:
bDisable = false;
break;
case SID_CUT: // cut case SID_CUT: // cut
case FID_INS_CELL: // insert cells, just simple selection case FID_INS_CELL: // insert cells, just simple selection
bDisable = (!bSimpleArea); bDisable = (!bSimpleArea);

View File

@@ -79,6 +79,10 @@
#include "scui_def.hxx" #include "scui_def.hxx"
#include <svx/dialogs.hrc> #include <svx/dialogs.hrc>
#include "scabstdlg.hxx" #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/ui/dialogs/XExecutableDialog.hpp>
#include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/lang/XInitialization.hpp>
@@ -901,6 +905,9 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
} }
} }
break; break;
case FID_FILL_SINGLE_EDIT:
ExecuteFillSingleEdit();
break;
case SID_RANDOM_NUMBER_GENERATOR_DIALOG: case SID_RANDOM_NUMBER_GENERATOR_DIALOG:
{ {
sal_uInt16 nId = ScRandomNumberGeneratorDialogWrapper::GetChildWindowId(); sal_uInt16 nId = ScRandomNumberGeneratorDialogWrapper::GetChildWindowId();
@@ -2771,6 +2778,36 @@ void ScCellShell::ExecuteSubtotals(SfxRequest& rReq)
delete pDlg; 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) IMPL_LINK_NOARG(ScCellShell, DialogClosed)
{ {
OSL_ENSURE( pImpl->m_pLinkedDlg, "ScCellShell::DialogClosed(): invalid request" ); OSL_ENSURE( pImpl->m_pLinkedDlg, "ScCellShell::DialogClosed(): invalid request" );