diff options
-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: { |