diff options
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" ); |