diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-05-02 15:30:20 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-05-02 15:43:46 -0400 |
commit | 56cce6fd8151a916e1be540ac18724b46d1b15fc (patch) | |
tree | 18eddb22ce667f8a999d96339b10577cf7c21084 /sc/source/ui/view/cellsh1.cxx | |
parent | dd9c9a69da7b22c4166391df082ac23878312a01 (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
Diffstat (limited to 'sc/source/ui/view/cellsh1.cxx')
-rw-r--r-- | sc/source/ui/view/cellsh1.cxx | 37 |
1 files changed, 37 insertions, 0 deletions
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" ); |