diff options
author | Justin Luth <justin_luth@sil.org> | 2015-08-05 15:04:28 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-08-12 14:43:04 +0000 |
commit | ff3c4f4c704977b2eec1dba1238b422537e413f3 (patch) | |
tree | b8a5ba7377a5c4fe88025d90d915d32177437d5e /sw/source/uibase/shells | |
parent | ce286dd9e143431044403b78afc1d237cb11acb6 (diff) |
tdf#73691 Implement MSWord's Alt-X: toggle unicode notation
-toggles between characters and their unicode notation
-sets Alt-X as a global keyboard accelerator
-handles all of the unicode planes
-intelligently handles combining characters
-if text is selected, limits the input to that text
-implemented in Writer, Draw, Impress
Change-Id: Idcd8e7f0a4f1b81fa7f5f3200c76be19472ffa37
Reviewed-on: https://gerrit.libreoffice.org/17535
Tested-by: Samuel Mehrbrodt <s.mehrbrodt@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'sw/source/uibase/shells')
-rw-r--r-- | sw/source/uibase/shells/textsh1.cxx | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx index 8dcff4199011..8f5e9cd64124 100644 --- a/sw/source/uibase/shells/textsh1.cxx +++ b/sw/source/uibase/shells/textsh1.cxx @@ -23,6 +23,7 @@ #include <cmdid.h> #include <helpid.h> +#include <i18nutil/unicode.hxx> #include <i18nlangtag/languagetag.hxx> #include <svl/languageoptions.hxx> #include <editeng/langitem.hxx> @@ -113,7 +114,7 @@ #include <tools/diagnose_ex.h> #include <svx/nbdtmgfact.hxx> #include <svx/nbdtmg.hxx> - +#include <SwRewriter.hxx> #include <svx/svdmodel.hxx> #include <svx/drawitem.hxx> #include <numrule.hxx> @@ -287,6 +288,35 @@ void SwTextShell::Execute(SfxRequest &rReq) pArgs->GetItemState(GetPool().GetWhich(nSlot), false, &pItem); switch( nSlot ) { + case SID_UNICODE_NOTATION_TOGGLE: + { + int nMaxUnits = 256; + if( rWrtSh.IsSelection() && !rWrtSh.IsMultiSelection() ) + nMaxUnits = rWrtSh.GetSelText().getLength(); + + int index = 0; + ToggleUnicodeCodepoint aToggle = ToggleUnicodeCodepoint(); + while( nMaxUnits-- && aToggle.AllowMoreInput(rWrtSh.GetChar(true, index-1)) ) + --index; + + OUString sReplacement = aToggle.ReplacementString(); + if( !sReplacement.isEmpty() ) + { + SwRewriter aRewriter; + aRewriter.AddRule( UndoArg1, aToggle.StringToReplace() ); + aRewriter.AddRule( UndoArg2, "->" ); + aRewriter.AddRule( UndoArg3, sReplacement ); + rWrtSh.StartUndo(UNDO_REPLACE, &aRewriter); + rWrtSh.GetCrsr()->Normalize(false); + rWrtSh.ClearMark(); + for( sal_uInt32 i=aToggle.CharsToDelete(); i > 0; --i ) + rWrtSh.DelLeft(); + rWrtSh.Insert2( sReplacement ); + rWrtSh.EndUndo(UNDO_REPLACE, &aRewriter); + } + } + break; + case SID_LANGUAGE_STATUS: { // get the language |