~nishimotz/nvdajp/releases_2011.1

« back to all changes in this revision

Viewing changes to nvdaHelper/nvdajpimeRPC/tsf.cpp

  • Committer: Takuya Nishimoto
  • Date: 2011-07-10 13:50:40 UTC
  • mfrom: (4072.1.59 releases_2011.1)
  • Revision ID: nishimotz@gmail.com-20110710135040-0zr5m6nwv0nm59up
merged mshinke revno 4131 (x64 application keyecho for IME)

Show diffs side-by-side

added added

removed removed

Lines of Context:
106
106
{
107
107
    LONG cr = --_cRef;
108
108
 
 
109
        HWND hwnd = NULL;
 
110
        HIMC himc = NULL;
 
111
    hwnd = GetFocus();
 
112
    if (hwnd)
 
113
        {
 
114
                himc = ImmGetContext(hwnd);
 
115
                if (himc)
 
116
                {
 
117
                        ImmSetOpenStatus(himc,FALSE);
 
118
                }
 
119
                ImmReleaseContext(hwnd, himc);
 
120
        }
 
121
        //MessageBox(NULL, L"IME", L"ステータス", MB_OK);
 
122
        
109
123
    assert(_cRef >= 0);
110
124
 
111
125
    if (_cRef == 0)
493
507
    if ((uSavedCompositionText != _uCompositionText) ||
494
508
        memcmp(pszSavedCompositionText, _pszCompositionText, _uCompositionText * sizeof(WCHAR)))
495
509
    {
496
 
                wsprintf(GetSharedMemory()->TextValue,L"%s",_pszCompositionText);       //@@ Masataka.Shinke
497
 
                GetSharedMemory()->TsfMode=TRUE;                                                                        //@@ Masataka.Shinke
498
 
                HANDLE hEvent = OpenEvent(EVENT_ALL_ACCESS, FALSE, EVENT_NAME);         //@@ Msataka.Shinke
499
 
                SetEvent(hEvent);                                                                                                       //@@ Msataka.Shinke
500
 
                CloseHandle(hEvent);                                                                                            //@@ Msataka.Shinke
 
510
                /////////////////////////////////////////////////////////////
 
511
                #ifdef NVDAJPIME_RPC
 
512
                        if(GetSharedMemory()->TsfMode)
 
513
                        {
 
514
                                wsprintf(GetSharedMemory()->TextValue,L"%s",_pszCompositionText);       
 
515
                                wsprintf(GetSharedMemory()->OldValue,L"%s",GetSharedMemory()->NewValue);
 
516
                                wsprintf(GetSharedMemory()->NewValue,L"%s",GetSharedMemory()->TextValue);
 
517
                                wsprintf(GetSharedMemory()->DiffValue,L"%s",Diff(GetSharedMemory()->OldValue,GetSharedMemory()->NewValue,GetSharedMemory()->OldKeyCode,GetSharedMemory()->NewKeyCode));
 
518
                                GetSharedMemory()->OldKeyCode=GetSharedMemory()->NewKeyCode;
 
519
                                if(GetSharedMemory()->TextValue[0]!=0)
 
520
                                {
 
521
                                                wchar_t desktopSpecificNamespace[64];
 
522
                                                generateDesktopSpecificNamespace(desktopSpecificNamespace,ARRAYSIZE(desktopSpecificNamespace));
 
523
                                                wstringstream s;
 
524
                                                s<<L"ncalrpc:[NvdaCtlr."<<desktopSpecificNamespace<<L"]";
 
525
                                                RpcBindingFromStringBinding((RPC_WSTR)(s.str().c_str()),&nvdaControllerBindingHandle);
 
526
 
 
527
                                                if(nvdajpimeRPC_testIfRunning()==0)
 
528
                                                {
 
529
                                                        nvdajpimeRPC_speakText(GetSharedMemory()->DiffValue);
 
530
                                                }
 
531
                                                RpcBindingFree(&nvdaControllerBindingHandle);
 
532
                                        }
 
533
                                        GetSharedMemory()->TsfMode = FALSE;
 
534
                        }       
 
535
                #else
 
536
                        //
 
537
                #endif
 
538
                
501
539
        }
502
540
 
503
541
    if (pszSavedCompositionText)
527
565
   }
528
566
 
529
567
   return cch;
530
 
}
 
 
b'\\ No newline at end of file'
 
568
}
 
569
 
 
570
//
 
571
//
 
572
//
 
573
WCHAR* CnvdajpimeTSF::Diff(WCHAR* pOld,WCHAR* pNew,UINT pFirstCode,UINT pLastCode)
 
574
{
 
575
 
 
576
        std::wstring Old(pOld);
 
577
        std::wstring New(pNew);
 
578
        std::wstring Dif(L"");
 
579
        WCHAR Ret[256]={NULL};
 
580
 
 
581
        if(!New.empty())
 
582
        {
 
583
                switch(pLastCode)
 
584
                {
 
585
                case 28:
 
586
                case 32:
 
587
                case 38:
 
588
                case 40:
 
589
                case 117:
 
590
                case 118:
 
591
                case 119:
 
592
                case 120:
 
593
                case 121:
 
594
                        if(New!=Old)
 
595
                                wsprintf(Ret,L"%s",New.c_str());
 
596
                        else if(pFirstCode!=pLastCode)                  //@@
 
597
                                wsprintf(Ret,L"%s",New.c_str());        //@@
 
598
                        else
 
599
                                wsprintf(Ret,L"%s",L"");
 
600
                        return &Ret[0];
 
601
                        break;
 
602
                default:
 
603
                        break;
 
604
                }
 
605
        }
 
606
 
 
607
        for(int i=(UINT)Old.length()-1,j=(UINT)New.length()-1;(i>=0)*(j>=0);i--,j--)    //@@
 
608
        {
 
609
                if(Old[i]!=New[j])
 
610
                {
 
611
                        Dif = New[j];
 
612
                        wsprintf(Ret,L"%s",Dif.c_str());
 
613
 
 
614
 
 
615
                        if((i>0)&(j>0))
 
616
                        {
 
617
                                if(Old[i-1]!=New[j-1])
 
618
                                {
 
619
 
 
620
                                        if( Dif.compare(std::wstring(L"ゃ")) == 0 )
 
621
                                                wsprintf(Ret,L"%s",New.substr(j-1,2).c_str());
 
622
                                        else if (Dif.compare(std::wstring(L"ゅ")) == 0 )
 
623
                                                wsprintf(Ret,L"%s",New.substr(j-1,2).c_str());
 
624
                                        else if (Dif.compare(std::wstring(L"ょ")) == 0 )
 
625
                                                wsprintf(Ret,L"%s",New.substr(j-1,2).c_str());
 
626
                                        else if (Dif.compare(std::wstring(L"ぁ")) == 0 )
 
627
                                                wsprintf(Ret,L"%s",New.substr(j-1,2).c_str());
 
628
                                        else if (Dif.compare(std::wstring(L"ぃ")) == 0 )
 
629
                                                wsprintf(Ret,L"%s",New.substr(j-1,2).c_str());
 
630
                                        else if (Dif.compare(std::wstring(L"ぉ")) == 0 )
 
631
                                                wsprintf(Ret,L"%s",New.substr(j-1,2).c_str());
 
632
 
 
633
 
 
634
                                        else if (Dif.compare(std::wstring(L"ャ")) == 0 )
 
635
                                                wsprintf(Ret,L"%s",New.substr(j-1,2).c_str());
 
636
                                        else if (Dif.compare(std::wstring(L"ュ")) == 0 )
 
637
                                                wsprintf(Ret,L"%s",New.substr(j-1,2).c_str());
 
638
                                        else if (Dif.compare(std::wstring(L"ョ")) == 0 )
 
639
                                                wsprintf(Ret,L"%s",New.substr(j-1,2).c_str());
 
640
                                        else if (Dif.compare(std::wstring(L"ァ")) == 0 )
 
641
                                                wsprintf(Ret,L"%s",New.substr(j-1,2).c_str());
 
642
                                        else if (Dif.compare(std::wstring(L"ィ")) == 0 )
 
643
                                                wsprintf(Ret,L"%s",New.substr(j-1,2).c_str());
 
644
                                        else if (Dif.compare(std::wstring(L"ォ")) == 0 )
 
645
                                                wsprintf(Ret,L"%s",New.substr(j-1,2).c_str());
 
646
 
 
647
 
 
648
                                        else if (Dif.compare(std::wstring(L"ャ")) == 0 )
 
649
                                                wsprintf(Ret,L"%s",New.substr(j-1,2).c_str());
 
650
                                        else if (Dif.compare(std::wstring(L"ュ")) == 0 )
 
651
                                                wsprintf(Ret,L"%s",New.substr(j-1,2).c_str());
 
652
                                        else if (Dif.compare(std::wstring(L"ョ")) == 0 )
 
653
                                                wsprintf(Ret,L"%s",New.substr(j-1,2).c_str());
 
654
                                        else if (Dif.compare(std::wstring(L"ァ")) == 0 )
 
655
                                                wsprintf(Ret,L"%s",New.substr(j-1,2).c_str());
 
656
                                        else if (Dif.compare(std::wstring(L"ィ")) == 0 )
 
657
                                                wsprintf(Ret,L"%s",New.substr(j-1,2).c_str());
 
658
                                        else if (Dif.compare(std::wstring(L"ォ")) == 0 )
 
659
                                                wsprintf(Ret,L"%s",New.substr(j-1,2).c_str());
 
660
 
 
661
 
 
662
                                }
 
663
                        }
 
664
 
 
665
 
 
666
                        break;
 
667
                }
 
668
                
 
669
        }
 
670
        if(Dif.empty() & (Old.length()<New.length()) )
 
671
        {
 
672
                Dif = New[New.length()-1];
 
673
                wsprintf(Ret,L"%s",Dif.c_str());
 
674
        }
 
675
 
 
676
        return &Ret[0];
 
677
}