ปัญหาดังกล่าวไม่สามารถทำได้บน OpenOffice.org เนื่องมาจาก key ที่ให้เราสามารถตั้งค่าการทำงานต่างๆ บน OpenOffice.org มีอยู่จำกัดและไม่สามารถเพิ่มเองได้เหมือนกับ Microsoft Office ดังนั้นผมจึงคิดว่าควรทำเป็น extension หรือ ง่ายกว่านั้นก็คือ macro
ดังนั้นผมจึงเขียนมาโครที่ทำการ convert ตัวเลขอาราบิกทั้งหมดภายในเอกสารให้กลายเป็นตัวเลขไทยซะดังนี้
sub main dim descriptor dim foundall dim found descriptor = ThisComponent.createSearchDescriptor() thainum = array("๐", "๑", "๒", "๓", "๔", "๕", "๖", "๗", "๘", "๙") for num = 0 to 9 with descriptor .SearchString = num .SearchCaseSensitive = False end with foundall = ThisComponent.findall(descriptor) for i = 0 to foundall.getcount() -1 found = foundall.getbyindex(i) found.setstring(thainum(num)) next next end sub
แค่นี้ เมื่อกดรันมาโครดังกล่าว ตัวเลขภายในเอกสารของเราก็จะกลายเป็นเลขไทยแล้ว
-----------------------------------------------------------
เพิ่มเติมอีกนิด สำหรับการแก้ไขเลขไทยเฉพาะส่วนที่คลุมครับ
sub mainselected dim leftpos dim rightpos dim found dim descriptor descriptor = ThisComponent.createSearchDescriptor() thainum = array("๐", "๑", "๒", "๓", "๔", "๕", "๖", "๗", "๘", "๙") for num = 0 to 9 with descriptor .SearchString = num .SearchCaseSensitive = False end with leftpos = thiscomponent.getcurrentcontroller().getviewcursor().getstart() rightpos = thiscomponent.getcurrentcontroller().getviewcursor().getend() found = thiscomponent.findnext(leftpos.getstart(), descriptor) do while not isnull(found) if -1 = thiscomponent.gettext().compareRegionEnds(found, rightpos) then exit do found.setstring(thainum(num)) found = thiscomponent.findnext(found.end, descriptor) loop next end sub
-----------------------------------------------------------
update
ทำเป็น extension เพื่อให้ติดตั้งแล้วใช้งานได้ทันทีครับ
download
เมื่อติดตั้งแล้วจะอยู่ที่เมนู format > convert to native number ครับโดยต้องคลุมก่อนแล้วเลือกใช้งานครับ