OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

unlocalized calc formula

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Code Snippets
View previous topic :: View next topic  
Author Message
Villeroy
Super User
Super User


Joined: 04 Oct 2004
Posts: 10106
Location: Germany

PostPosted: Tue Aug 30, 2005 12:29 pm    Post subject: unlocalized calc formula Reply with quote

This one shows an inputbox with the unlocalized (english) formula of the active cell. Displays an input box with the unlocalized formula of active cell. You can paste an unlocalized formula into the input box in order to put the localized version into the cell.
Install: Tools>Macros>Organize>Basic ... Paste the code into a new module or any existing one in container "My Macros".
Call: Tools>Macros>Run... or assign some shortcut/button/menu to the installed macro (Tools>Customize...).
2006-08-09: fixed error in getFocussedCell when row > 8191
Code:

Sub showENFormula
Dim oCell as object,sFml$
   oCell = thisComponent.CurrentController.Selection
   if NOT hasUnoInterfaces(oCell,"com.sun.star.table.Cell") then
      oCell = GetFocussedCell(thisComponent,false)
   end if
   sFml = oCell.getFormula()
   sFml = inputbox("Unlocalized Formula of Focussed Cell:","showENFormula",sFml)
   if sFml <> "" then oCell.setFormula(sFml)
End Sub
'-------usefull helper-function, returning focussed cell or it's address
'by UROS > http://www.oooforum.org/forum/viewtopic.phtml?t=19348
REM 2006-08-09: fixed error when row > 8191
'100/60/0;1;tw:309;2/2/0/0/0/0/2/0/0/0/0;253/8191/0/0/0/0/2/246/0/0/8158;0/0/0/0/0/0/2/0/0/0/0
'100/60/0;1;tw:309;2/2/0/0/0/0/2/0/0/0/0;253+8192+0+0+0+0+2+246+0+0+8158;0/0/0/0/0/0/2/0/0/0/0
Function GetFocussedCell(oDoc as Object,bAddr as Boolean) as Object
Dim as1(), lSheet&,lCol&,lRow$, sDum as String,bErr as Boolean
   as1()  = Split(oDoc.currentController.ViewData, ";")
   lSheet = CLng(as1(1))
   sDum = as1(lSheet +3)
   as1() = Split(sDum, "/")
   on error goto errSlash
      lCol = CLng(as1(0))
      lRow = CLng(as1(1))
   on error goto 0
   if bAddr then
      GetFocussedCell = oDoc.getSheets.getByIndex(lSheet).getcellByPosition(lCol,lRow).getCellAddress
   else
      GetFocussedCell = oDoc.getSheets.getByIndex(lSheet).getcellByPosition(lCol,lRow)
   end if
exit Function
errSlash:
   if NOT(bErr) then
      bErr = True
      as1() = Split(sDum, "+")
      resume
   endif
End Function

Any addin-functions must be localized manually in the input box or specified by their full service-name like this:
sheet-function[addin] MROUND ---> com.sun.star.sheet.addin.Analysis.getMround
or manually MROUND ---> VRUNDEN [german translation]
Back to top
View user's profile Send private message
eduzs
OOo Advocate
OOo Advocate


Joined: 07 Feb 2005
Posts: 356
Location: RJ, BRAZIL

PostPosted: Fri Aug 10, 2007 5:05 pm    Post subject: Reply with quote

Great. But I need to do this from english to portuguese.
Is that possible to change this code to do this?

Thanks
_________________
BrOffice.org 3.2.1
Back to top
View user's profile Send private message
Villeroy
Super User
Super User


Joined: 04 Oct 2004
Posts: 10106
Location: Germany

PostPosted: Sat Aug 11, 2007 1:10 am    Post subject: Reply with quote

eduzs wrote:
Great. But I need to do this from english to portuguese.
Is that possible to change this code to do this?

Thanks

Please give a try. Read the description and the code of sub showENFormula. The macro gets and sets the unlocalized formula of a cell.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Code Snippets All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group