summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorJustin Luth <justin_luth@sil.org>2015-08-05 15:04:28 +0300
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-08-12 14:43:04 +0000
commitff3c4f4c704977b2eec1dba1238b422537e413f3 (patch)
treeb8a5ba7377a5c4fe88025d90d915d32177437d5e /sd
parentce286dd9e143431044403b78afc1d237cb11acb6 (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 'sd')
-rw-r--r--sd/sdi/_drvwsh.sdi4
-rw-r--r--sd/sdi/sdraw.sdi23
-rw-r--r--sd/source/ui/view/drviewse.cxx42
3 files changed, 69 insertions, 0 deletions
diff --git a/sd/sdi/_drvwsh.sdi b/sd/sdi/_drvwsh.sdi
index 2a721d8a7038..2f7769be816b 100644
--- a/sd/sdi/_drvwsh.sdi
+++ b/sd/sdi/_drvwsh.sdi
@@ -96,6 +96,10 @@ interface DrawView
ExecMethod = FuSupport ;
StateMethod = GetMenuState ;
]
+ SID_UNICODE_NOTATION_TOGGLE
+ [
+ ExecMethod = FuSupport;
+ ]
SID_PASTE_UNFORMATTED
[
ExecMethod = FuSupport ;
diff --git a/sd/sdi/sdraw.sdi b/sd/sdi/sdraw.sdi
index d91e21bec36f..5fd19ad8bde8 100644
--- a/sd/sdi/sdraw.sdi
+++ b/sd/sdi/sdraw.sdi
@@ -7208,4 +7208,27 @@ SfxVoidItem MovePageLast SID_MOVE_PAGE_LAST
ToolBoxConfig = TRUE,
GroupId = GID_MODIFY;
]
+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;
+]
diff --git a/sd/source/ui/view/drviewse.cxx b/sd/source/ui/view/drviewse.cxx
index 0eb9f29177c4..093b46d31665 100644
--- a/sd/source/ui/view/drviewse.cxx
+++ b/sd/source/ui/view/drviewse.cxx
@@ -22,6 +22,7 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/i18n/TransliterationModules.hpp>
#include <com/sun/star/i18n/TransliterationModulesExtra.hpp>
+#include <i18nutil/unicode.hxx>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/uno/Any.hxx>
@@ -837,6 +838,47 @@ void DrawViewShell::FuSupport(SfxRequest& rReq)
}
break;
+ case SID_UNICODE_NOTATION_TOGGLE:
+ {
+ if ( mpDrawView->IsTextEdit() )
+ {
+ OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
+ if (pOLV)
+ {
+ OUString sInput = pOLV->GetSurroundingText();
+ ESelection aSel( pOLV->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);
+ //The mouse can set the cursor in the middle of a multi-unit character,
+ // so reset to the proper end of the logical characters
+ 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() )
+ {
+ OUString sStringToReplace = aToggle.StringToReplace();
+ mpDrawView->BegUndo(sStringToReplace +"->"+ sReplacement);
+ aSel.nStartPos = aSel.nEndPos - sStringToReplace.getLength();
+ pOLV->SetSelection( aSel );
+ pOLV->InsertText(sReplacement, true);
+ mpDrawView->EndUndo();
+ }
+ }
+ }
+ }
+ break;
+
case SID_PASTE_UNFORMATTED:
{
WaitObject aWait( GetActiveWindow() );