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:
parent
dd9c9a69da
commit
56cce6fd81
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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; ]
|
||||
|
@ -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
|
||||
()
|
||||
[
|
||||
|
@ -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();
|
||||
|
@ -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()
|
||||
|
@ -61,6 +61,8 @@ private:
|
||||
void ExecuteXMLSourceDialog();
|
||||
void ExecuteSubtotals(SfxRequest& rReq);
|
||||
|
||||
void ExecuteFillSingleEdit();
|
||||
|
||||
DECL_LINK( ClipboardChanged, TransferableDataHelper* );
|
||||
DECL_LINK( DialogClosed, void* );
|
||||
|
||||
|
@ -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); }
|
||||
|
@ -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);
|
||||
|
@ -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" );
|
||||
|
Loading…
x
Reference in New Issue
Block a user