sc/sdi/editsh.sdi | 2 ++ sc/sdi/scalc.sdi | 24 ++++++++++++++++++++++++ sc/source/ui/view/editsh.cxx | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+)
New commits: commit 7c9a484249da249dea7129ca93f5d1cbf5fbe462 Author: Justin Luth <[email protected]> Date: Mon Sep 14 07:39:25 2015 +0300 tdf#73691 - add alt-x support to calc Alt-X (Unicode notation toggling) was added to Writer and Draw/Impress in earlier. This adds it to Calc as well. Change-Id: Ieb5188b9ff35cb35941c36d22292069723df80b6 Reviewed-on: https://gerrit.libreoffice.org/18558 Tested-by: Jenkins <[email protected]> Reviewed-by: Samuel Mehrbrodt <[email protected]> Tested-by: Samuel Mehrbrodt <[email protected]> diff --git a/sc/sdi/editsh.sdi b/sc/sdi/editsh.sdi index 52cc6b4..b5c35c9 100644 --- a/sc/sdi/editsh.sdi +++ b/sc/sdi/editsh.sdi @@ -43,6 +43,8 @@ interface TableText SID_REDO [ ExecMethod = ExecuteUndo; StateMethod = GetUndoState; Export = FALSE; ] SID_REPEAT [ ExecMethod = ExecuteUndo; StateMethod = GetUndoState; Export = FALSE; ] + SID_UNICODE_NOTATION_TOGGLE [ ExecMethod = Execute; Export = FALSE; ] + // ---- Attribute: SID_ATTR_CHAR_FONT [ ExecMethod = ExecuteAttr; StateMethod = GetAttrState; Export = FALSE; ] SID_ATTR_CHAR_FONTHEIGHT [ ExecMethod = ExecuteAttr; StateMethod = GetAttrState; Export = FALSE; ] diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi index 1fade23..a33801b 100644 --- a/sc/sdi/scalc.sdi +++ b/sc/sdi/scalc.sdi @@ -8903,6 +8903,30 @@ SfxVoidItem ConvertFormulaToValue SID_CONVERT_FORMULA_TO_VALUE GroupId = GID_OPTIONS; ] +SfxVoidItem UnicodeNotationToggle SID_UNICODE_NOTATION_TOGGLE +() +[ + /* flags: */ + AutoUpdate = FALSE, + Cachable = Cachable, + FastCall = FALSE, + HasCoreId = FALSE, + HasDialog = FALSE, + ReadOnlyDoc = FALSE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + Synchron; + + /* config: */ + AccelConfig = TRUE, + MenuConfig = FALSE, + StatusBarConfig = FALSE, + ToolBoxConfig = FALSE, + GroupId = GID_OPTIONS; +] + SfxVoidItem ShowDetail SID_OUTLINE_SHOW () [ diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx index 846d780..c95251e 100644 --- a/sc/source/ui/view/editsh.cxx +++ b/sc/source/ui/view/editsh.cxx @@ -21,6 +21,7 @@ #include <comphelper/string.hxx> #include "scitems.hxx" #include <editeng/eeitem.hxx> +#include <i18nutil/unicode.hxx> #include <svx/clipfmtitem.hxx> #include <svx/svxdlg.hxx> @@ -331,6 +332,46 @@ void ScEditShell::Execute( SfxRequest& rReq ) bSetModified = false; } return; + case SID_UNICODE_NOTATION_TOGGLE: + { + EditView* pActiveView = pHdl ? pHdl->GetActiveView() : pEditView; + if( pActiveView ) + { + OUString sInput = pEngine->GetText(); + ESelection aSel( pActiveView->GetSelection() ); + if( aSel.HasRange() ) + sInput = pActiveView->GetSelected(); + + if( aSel.nStartPos > aSel.nEndPos ) + aSel.nEndPos = aSel.nStartPos; + + //calculate a valid end-position by reading logical characters + sal_Int32 nUtf16Pos=0; + while( (nUtf16Pos < sInput.getLength()) && (nUtf16Pos < aSel.nEndPos) ) + { + sInput.iterateCodePoints(&nUtf16Pos); + if( nUtf16Pos > aSel.nEndPos ) + aSel.nEndPos = nUtf16Pos; + } + + ToggleUnicodeCodepoint aToggle = ToggleUnicodeCodepoint(); + while( nUtf16Pos && aToggle.AllowMoreInput( sInput[nUtf16Pos-1]) ) + --nUtf16Pos; + OUString sReplacement = aToggle.ReplacementString(); + if( !sReplacement.isEmpty() ) + { + aSel.nStartPos = aSel.nEndPos - aToggle.StringToReplace().getLength(); + pTableView->SetSelection( aSel ); + pTableView->InsertText(sReplacement, true); + if( pTopView ) + { + pTopView->SetSelection( aSel ); + pTopView->InsertText(sReplacement, true); + } + } + } + } + break; case SID_CHARMAP: { _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
