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 /include | |
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 'include')
-rw-r--r-- | include/i18nutil/unicode.hxx | 46 | ||||
-rw-r--r-- | include/sfx2/sfxcommands.h | 1 | ||||
-rw-r--r-- | include/sfx2/sfxsids.hrc | 1 |
3 files changed, 48 insertions, 0 deletions
diff --git a/include/i18nutil/unicode.hxx b/include/i18nutil/unicode.hxx index 6561da039f6b..051da5bd9188 100644 --- a/include/i18nutil/unicode.hxx +++ b/include/i18nutil/unicode.hxx @@ -21,6 +21,7 @@ #include <com/sun/star/i18n/UnicodeScript.hpp> #include <sal/types.h> +#include <rtl/ustrbuf.hxx> #include <unicode/uscript.h> #include <i18nutil/i18nutildllapi.h> @@ -58,6 +59,51 @@ public: const LanguageTag &rLangTag); }; +/* + Toggle between a character and its Unicode Notation. + -implements the concept found in Microsoft Word's Alt-X + -accepts sequences of up to 8 hex characters and converts into the corresponding Unicode Character + -example: 0000A78c or 2bc + -accepts sequences of up to 256 characters in Unicode notation + -example: U+00000065u+0331u+308 + -handles complex characters (with combining elements) and the all of the Unicode planes. +*/ +class I18NUTIL_DLLPUBLIC ToggleUnicodeCodepoint +{ +private: + OUStringBuffer maInput; + OUStringBuffer maOutput; + OUStringBuffer maUtf16; + OUStringBuffer maCombining; + bool mbAllowMoreChars = true; + bool mbRequiresU = false; + bool mbIsHexString = false; + +public: + ToggleUnicodeCodepoint(); + + /** + Build an input string of valid UTF16 units to toggle. + -do not call the other functions until the input process is complete + -build string from Right to Left. (Start from the character to the left of the cursor: move left.) + */ + bool AllowMoreInput(sal_Unicode uChar); + + /** + Validates (and potentially modifies) the input string. + -all non-input functions must use this function to first to validate the input string + -additional input may be prevented after this function is called + */ + OUString StringToReplace(); + OUString ReplacementString(); + + /** + While sInput.getLength() returns the number of utf16 units to delete, + this function returns the number of "characters" to delete - potentially a smaller number + */ + sal_uInt32 CharsToDelete(); +}; + #endif diff --git a/include/sfx2/sfxcommands.h b/include/sfx2/sfxcommands.h index a5ac9fcea749..94c86a22f212 100644 --- a/include/sfx2/sfxcommands.h +++ b/include/sfx2/sfxcommands.h @@ -46,6 +46,7 @@ #define CMD_SID_PRINTPREVIEW ".uno:PrintPreview" #define CMD_SID_RELOAD ".uno:Reload" #define CMD_SID_BASICIDE_RENAMECURRENT ".uno:RenameCurrent" +#define CMD_SID_UNICODE_NOTATION_TOGGLE ".uno:UnicodeNotationToggle" #endif diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc index 1755eb5ad712..c8af8726c5aa 100644 --- a/include/sfx2/sfxsids.hrc +++ b/include/sfx2/sfxsids.hrc @@ -415,6 +415,7 @@ #define SID_OBJECTMENU3 (SID_SFX_START + 783) #define SID_OBJECTMENU_LAST SID_OBJECTMENU3 #define SID_FORMATMENUSTATE (SID_SFX_START + 791) +#define SID_UNICODE_NOTATION_TOGGLE (SID_SFX_START + 792) // default-ids for macros #define SID_RECORDING_FLOATWINDOW (SID_SFX_START + 800) |