2006年05月7日

[OOo] 輸入數值產生Unicode字元的巨集

Iannz OpenOffice.org page看到的巨集:AltKeyHandler,設定後卻無法讓Alt按鍵正確的執行,不知那裡發生錯誤,還需要再測試看看。

其內有個雜項巨集:HexUnicode,可以輸入一個十六進位的值來插入特定字元,我稍微做了點修改並改名為HexToUnicode,將執行步驟彙總如下:
  1. 【工具→巨集→組織巨集→OpenOffice.org Basic...】
  2. 在巨集的來源框裡選【我的巨集→Standard】,按最右方的「開啟新檔」
  3. 【新的模塊】對話窗裡給新的名稱:HexToUnicode
  4. 按確定後會進入程式編輯畫面,將下列程式貼上:
    REM  *****  BASIC  *****

    ' from http://homepages.paradise.net.nz/hillview/OOo/
    sub HexToUnicode
    on local error goto finished
    n = inputbox("Unicode 16進位值:")
    ch = chr(clng("&h" & n)
    myDispatch("InsertText", array("Text",ch))
    finished:
    end sub

    function myDispatch(sCommand as string, optional mArgs)
    oFrame = ThisComponent.CurrentController.Frame
    oDispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
    'on error resume next
    if isMissing(mArgs) then
        fnDispatch = oDispatcher.executeDispatch(oFrame, ".uno:" & sCommand, "", 0, array())
    else
        nArgs = uBound(mArgs) \ 2
        dim Args(nArgs) as new com.sun.star.beans.PropertyValue
        for i = 0 to nArgs
            Args(i).name = mArgs(i * 2)
            Args(i).value = mArgs(i * 2 + 1)
        next
        fnDispatch = oDispatcher.executeDispatch(oFrame, ".uno:" & sCommand, "", 0, Args())
    end if
    end function
  5. 儲存後離開編輯視窗
巨集程式輸入完畢後,進入工具→自訂→選鍵盤頁籤,設定一個按鍵給巨集HexToUnicode:
  1. 指定按鍵,此處用Ctrl+N
  2. 找到HexToUnicode巨集
  3. 按右上方的變更
  4. 按確定回到文件
Customize 1

接著在需要插入字元的地方按下Ctrl+N即會出現對話框,輸入十六進位的數值並按確定就能插入該數值代表的Unicode字元。

但是,我們要由那裡知道Unicode數值與其字元的對照呢?其實在Writer裡,在需要插入字元的對話框裡只要按「Ctrl+Shift+S」 就能開啟特殊字元窗,因此先按下Ctrl+N,再按Ctrl+Shift+S,即可看到特殊字元窗,由此視窗就能看到常用字元的Unicode了。下圖右下角的U+2460就是圓圈1的十六進位值,因此在紅框裡輸入2460按確定即可。
HexToUnicode 2
##

Add to Furl   Add to del.icio.us

Posted by emisjerry at 樂多Roodo! │23:59 │引用(0)OpenOffice.org試用手記
樂多分類:網路/3C 共同主題:Utilities/Tools 工具:編輯本文
Ads by Roodo! 

引用URL

http://cgi.blog.roodo.com/trackback/1551282