From ff3c4f4c704977b2eec1dba1238b422537e413f3 Mon Sep 17 00:00:00 2001 From: Justin Luth Date: Wed, 5 Aug 2015 15:04:28 +0300 Subject: 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 Reviewed-by: Miklos Vajna --- include/i18nutil/unicode.hxx | 46 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'include/i18nutil/unicode.hxx') 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 #include +#include #include #include @@ -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 -- cgit