diff options
author | Justin Luth <justin_luth@sil.org> | 2015-10-13 16:42:16 +0300 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2015-10-15 13:36:37 +0000 |
commit | 6212c467156e2bd4580a9f8145124223d3135ea4 (patch) | |
tree | 67e83831c825c0f1c6c69baa9386d5d68bfb89b1 /starmath | |
parent | d3465703c9d6f7a6277398337a5e9df3a8df0d19 (diff) |
tdf#73691 - add alt-x support to math
At the request of bug tdf#94957, adding unicode conversion
shortcut (alt+x) to Math also.
Change-Id: I5b4d17543a819f035ade0d9a516eeef8542a286e
Reviewed-on: https://gerrit.libreoffice.org/19323
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'starmath')
-rw-r--r-- | starmath/sdi/smath.sdi | 25 | ||||
-rw-r--r-- | starmath/sdi/smslots.sdi | 4 | ||||
-rw-r--r-- | starmath/source/view.cxx | 47 |
3 files changed, 76 insertions, 0 deletions
diff --git a/starmath/sdi/smath.sdi b/starmath/sdi/smath.sdi index bbf5a6bedb6f..29d4c60ac76d 100644 --- a/starmath/sdi/smath.sdi +++ b/starmath/sdi/smath.sdi @@ -800,6 +800,31 @@ SfxStringItem TextStatus SID_TEXTSTATUS ] +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 ToolBoxWindow SID_TOOLBOXWINDOW () [ diff --git a/starmath/sdi/smslots.sdi b/starmath/sdi/smslots.sdi index a43eb7c38bff..d00382d2bd18 100644 --- a/starmath/sdi/smslots.sdi +++ b/starmath/sdi/smslots.sdi @@ -291,6 +291,10 @@ interface FormulaView ExecMethod = Execute ; StateMethod = GetState ; ] + SID_UNICODE_NOTATION_TOGGLE + [ + ExecMethod = Execute; + ] //idlpp kein Menueeintrag , also keine Texte SID_TOOLBOXWINDOW //idlpp ole : no , status : no [ diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx index ad512b1d50d8..07cfe8c5727c 100644 --- a/starmath/source/view.cxx +++ b/starmath/source/view.cxx @@ -29,6 +29,7 @@ #include <comphelper/processfactory.hxx> #include <comphelper/storagehelper.hxx> #include <comphelper/string.hxx> +#include <i18nutil/unicode.hxx> #include <sfx2/app.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/docfile.hxx> @@ -52,6 +53,7 @@ #include <svx/dialogs.hrc> #include <svx/zoomslideritem.hxx> #include <editeng/editeng.hxx> +#include <editeng/editview.hxx> #include <svx/svxdlg.hxx> #include <sfx2/zoomitem.hxx> #include <vcl/decoview.hxx> @@ -1844,6 +1846,51 @@ void SmViewShell::Execute(SfxRequest& rReq) } break; + case SID_UNICODE_NOTATION_TOGGLE: + { + EditEngine* pEditEngine = 0; + if( pWin ) + pEditEngine = pWin->GetEditEngine(); + + EditView* pEditView = 0; + if( pEditEngine ) + pEditView = pEditEngine->GetView(); + + if( pEditView ) + { + const OUString sInput = pEditView->GetSurroundingText(); + ESelection aSel( pWin->GetSelection() ); + + 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; + while( nUtf16Pos && aToggle.AllowMoreInput( sInput[nUtf16Pos-1]) ) + --nUtf16Pos; + const OUString sReplacement = aToggle.ReplacementString(); + if( !sReplacement.isEmpty() ) + { + pEditView->SetSelection( aSel ); + pEditEngine->UndoActionStart(EDITUNDO_REPLACEALL); + aSel.nStartPos = aSel.nEndPos - aToggle.StringToReplace().getLength(); + pWin->SetSelection( aSel ); + pEditView->InsertText( sReplacement, true ); + pEditEngine->UndoActionEnd(EDITUNDO_REPLACEALL); + pWin->Flush(); + } + } + } + break; + case SID_SYMBOLS_CATALOGUE: { |