diff options
author | Justin Luth <justin_luth@sil.org> | 2015-09-14 07:39:25 +0300 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2015-09-15 06:48:35 +0000 |
commit | 7c9a484249da249dea7129ca93f5d1cbf5fbe462 (patch) | |
tree | 212519beb0a4afadcf8773abcc6083e900bddbc4 /sc | |
parent | e9e5fee720eb72fe789651861f48982d3d87674d (diff) |
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 <ci@libreoffice.org>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/sdi/editsh.sdi | 2 | ||||
-rw-r--r-- | sc/sdi/scalc.sdi | 24 | ||||
-rw-r--r-- | sc/source/ui/view/editsh.cxx | 41 |
3 files changed, 67 insertions, 0 deletions
diff --git a/sc/sdi/editsh.sdi b/sc/sdi/editsh.sdi index 52cc6b4ac564..b5c35c99bcdf 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 1fade23d0ff5..a33801ba923f 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 846d780649d7..c95251e0d115 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: { |