[api-dev] Re: Custom types drives me nuts – this can't be happening… can it?
Oh my goodness! It is always something small that wastes hours of time. On 08/15/2011 08:48 AM, Johnny Rosenberg wrote: Okej, forget this, I solved it. Immediately after I sent this I found the problem! All I needed to do to find it out was probably to write about it somewhere… I found the problem when I did a search in all modules for my type ”DieStatistics”. I found it in a module called ”Experiment” which is Swedish for ”Experiments” in this case. I did some tests in that module a few days ago, before I declared DiceFreq as an array of DieStatistics, so DiceFreq was declared globally twice: Module Experiment: Global DiceFreq As DieStatistics Module P: Private DiceFreq(1) As DieStatistics After removing the Experiment ones, everything worked as expected. Phew, what a relief… I thought I was crazy there for a few minutes…! And I usually don't top post, but in this case I thought it could be appropriate, since the text below suddenly became very unimportant. Best regards Johnny Rosenberg ジョニー・ローゼンバーグ 2011/8/15 Johnny Rosenberggurus.knu...@gmail.com: I was editing some code I have, actually a game with dice and stuff, but that doesn't matter, I suppose. So I ran into a problem, and I copied the troubling part of the code to a separate document for test driving. However, the test code runs perfectly, but not within the game of mine! I ran the game on another computer but another version of OpenOffice.org (actually the first computer runs LibreOffice 3.3.3), but the results were exactly the same. Here's the test code. I have a message box after almost every statement so I can see what happens. I added some extra comments in the code. REM * BASIC * Option Explicit Option Compatible Type DieStatistics Value As Integer Count As Integer End Type ' The variable DiceFreq, declared below this comment, tells us which two die values that are most frequent. For example, if the six dice are 133455, ' DiceFreq will contain: ' DiceFreq(0).Value: 5 (the most common value is 5) ' DiceFreq(0).Count: 2 (2 dice have the value 5) ' DiceFreq(1).Value: 3 (the second most common value is 3 – in this case there are two of both 3 and five, but higher value has priority) ' DiceFreq(1).Count: 2 (2 dice have the value 3) ' This makes it very easy for us to calculate things later, calculations that are not present in this short example though. Private DiceFreq(1) As DieStatistics ' Sub Test0 ' NDice tells us how many there are of each die value. In the above example, NDice(4)=1, since there are 1 die with the value 4. Dim NDice(1 To 6) As Integer, i As Integer ' Here we set the values of NDice for an example where this is known to fail, that is what NDice would contain if the dice were 112345 ' NDice(1)=2, NDice(2)=1 and so on. For i=2 To 5 NDice(i)=1 Next i NDice(1)=2 ' Here's where I calculate the values for DiceFreq by going through NDice from 6 to 1. For i=6 To 1 Step -1 If NDice(i)DiceFreq(0).Count Then DiceFreq(1).Count=DiceFreq(0).Count DiceFreq(1).Value=DiceFreq(0).Value MsgBox DiceFreq(0).Value : DiceFreq(0).Count st. Chr(13) _ DiceFreq(1).Value : DiceFreq(1).Count st. DiceFreq(0).Count=NDice(i) DiceFreq(0).Value=i MsgBox DiceFreq(0).Value : DiceFreq(0).Count st. Chr(13) _ DiceFreq(1).Value : DiceFreq(1).Count st. ElseIf NDice(i)DiceFreq(1).Count Then DiceFreq(1).Count=NDice(i) DiceFreq(1).Value=i MsgBox DiceFreq(0).Value : DiceFreq(0).Count st. Chr(13) _ DiceFreq(1).Value : DiceFreq(1).Count st. EndIf Next i MsgBox Final reults: String(2,Chr(13)) DiceFreq(0).Value : DiceFreq(0).Count _ st. Chr(13) DiceFreq(1).Value : DiceFreq(1).Count st. End Sub Now, while this works perfectly as a stand-alone subroutine, it doesn't work in the game. What happens in the game is that everytime I change the value of DiceFreq(i).Value or DiceFreq(i).Count, BOTH instances are changed, for example if I set DiceFreq(0).Value to 5, DiceFreq(1).Value is also set to 5 and I just can't figure out why! In the game the corresponding subroutine is called from another module, but I simulated that too in my test, but still it ONLY fails in the game. I can upload my game document (the debug version) somewhere if needed. What on earth could possibly cause this? I'm just out of ideas! Help…? Kind regards Johnny Rosenberg ジョニー・ローゼンバーグ -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt Info: http://www.pitonyak.org/oo.php --
[api-dev] Re: Global variables – OpenOffice.org Basic
On 08/14/2011 01:45 AM, Johnny Rosenberg wrote: 011/8/14 Andrew Douglas Pitonyakand...@pitonyak.org: Let me start by saying that this works just fine using OOo for all cases without resorting to Global. Do you have Option Compatible set anywhere? No, isn't that for compatibility with Visual Basic? I'm not sure why I would like to be compatible with that… Dim translates to Private, but Private is broken in OOo so it acts like Public. A decision was made to NOT fix this in case it broke existing macros. The end result is that DIM acts correctly ONLY if Option Compatible is used. Anyway, it worked (as far as I remember) without Global, but NOT from the IDE by pressing F5 in some cases. Kind regards Johnny Rosenberg ジョニー・ローゼンバーグ On 08/08/2011 11:42 AM, Johnny Rosenberg wrote: I am testing some functions at the moment (I wrote them a few years ago and now I'm trying to make them faster…) but I am a bit stuck at the moment. It looks something like this: Module1 ¯¯¯ ' Code starts here Option Explicit Type Blahblah This As Integer That As Integer End Type Dim OneThing As Blahblah Dim MoreStuff As Integer Sub Main Dim X As Integer Some stuff X=MyFunction(47) More stuff End Sub ' End of code Module2 ¯¯¯ ' Code starts here Function MyFunction(A As Integer) As Integer Dim SomeValue As Integer Some stuff OneThing.This=A*SomeValue More stuff MyFunction=OneThing.This-A End Function ' End of code Now, when running this (with F5 or F8), it seems like it starts at ”Sub Main” and everything above it is omitted, so I get an error message in module2 when ”OneThing” is mentioned. Shouldn't the global things be available in all modules? They are if I run similar macros from a spreadsheet, for example, that is not from the Basic IDE. Did I miss something here? Is there a way around it? Kind regards Johnny Rosenberg ジョニー・ローゼンバーグ -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt Info: http://www.pitonyak.org/oo.php -- - To unsubscribe send email to dev-unsubscr...@api.openoffice.org For additional commands send email to sy...@api.openoffice.org with Subject: help -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt Info: http://www.pitonyak.org/oo.php -- - To unsubscribe send email to dev-unsubscr...@api.openoffice.org For additional commands send email to sy...@api.openoffice.org with Subject: help
[api-dev] Re: How can I read my code in a module in the Basic IDE with Basic code?
I believe that AndrewBase.odt has an example that writes code to a module and then calls it. I also believe that it demonstrates how to walk controls and similar. On 08/14/2011 02:11 AM, Johnny Rosenberg wrote: My workaround at the moment, is to first save my code to a file and then loading it from the file. Not that it matters why I want to do this, but I am writing a macro that examines my subroutines and functions. I want to know the name of every function and every subroutine, what module they are in, what parameters they want, what they return, which subroutines and functions (of those in the same modules) they call, by which functions and subroutines they are called and maybe some more. My macro works, but as I said, it reads the information from files rather than directly from the modules in the Basic IDE. If I only can read all the text in one module at once, that would do it just fine. If there is a simple one-liner that reads just one function or subroutine, that's a bonus, and if I can read a dialogue that's even better… I know how to read from spreadsheets and writer documents, I just can't figure out how to reach the text in the IDE. Hoping for an answer even though I noticed that this list seems quite dead these days. Maybe people are busy doing real things… Kind regards Johnny Rosenberg ジョニー・ローゼンバーグ -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt Info: http://www.pitonyak.org/oo.php -- - To unsubscribe send email to dev-unsubscr...@api.openoffice.org For additional commands send email to sy...@api.openoffice.org with Subject: help
[api-dev] Re: Global variables – OpenOffice.org Basic
Let me start by saying that this works just fine using OOo for all cases without resorting to Global. Do you have Option Compatible set anywhere? On 08/08/2011 11:42 AM, Johnny Rosenberg wrote: I am testing some functions at the moment (I wrote them a few years ago and now I'm trying to make them faster…) but I am a bit stuck at the moment. It looks something like this: Module1 ¯¯¯ ' Code starts here Option Explicit Type Blahblah This As Integer That As Integer End Type Dim OneThing As Blahblah Dim MoreStuff As Integer Sub Main Dim X As Integer Some stuff X=MyFunction(47) More stuff End Sub ' End of code Module2 ¯¯¯ ' Code starts here Function MyFunction(A As Integer) As Integer Dim SomeValue As Integer Some stuff OneThing.This=A*SomeValue More stuff MyFunction=OneThing.This-A End Function ' End of code Now, when running this (with F5 or F8), it seems like it starts at ”Sub Main” and everything above it is omitted, so I get an error message in module2 when ”OneThing” is mentioned. Shouldn't the global things be available in all modules? They are if I run similar macros from a spreadsheet, for example, that is not from the Basic IDE. Did I miss something here? Is there a way around it? Kind regards Johnny Rosenberg ジョニー・ローゼンバーグ -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt Info: http://www.pitonyak.org/oo.php -- - To unsubscribe send email to dev-unsubscr...@api.openoffice.org For additional commands send email to sy...@api.openoffice.org with Subject: help
[api-dev] Re: Getting information from some site via Basic IDE – possible? How?
Wow Johnny, you sure do get around :-) On 07/16/2011 11:34 AM, Johnny Rosenberg wrote: Is it possible with the OpenOffice.org BASIC IDE to access a web site, login, copy some text to the clipboard, and then logout? Any hints? I have seen examples using Calc using tricks similar to these: http://www.openofficetips.com/blog/archives/2004/11/webquery_scrapi.html http://www.oooforum.org/forum/viewtopic.phtml?t=4103 In these examples, there was no need to login. The important point is that they simply loaded the page. I am not aware of a simple way to get the web contents without loading it into a document. My fear is that the login step will fail unless you are able to pass the credentials as part of the initial http request. I expect that the rest of the task is easy if you can solve the first part. Interested in seeing any solutions that you find or create. Kind regards Johnny Rosenberg ジョニー・ローゼンバーグ -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt Info: http://www.pitonyak.org/oo.php -- - To unsubscribe send email to dev-unsubscr...@api.openoffice.org For additional commands send email to sy...@api.openoffice.org with Subject: help
[api-dev] Re: Proper way to find an existing number format style.
On 05/31/2011 05:37 AM, Niklas Nebel wrote: On 31.05.2011 07:34, Andrew Douglas Pitonyak wrote: Tested on 3.3.0 en-US using the 64-bit Linux version on Fedora 15. I use the following macro to find an existing number format, and I create it if it does not exist. The problem is that oDoc.getNumberFormats().queryKey(sFormat, aLocale, True) fails to find user created numeric formats, it only returns a value for for formats strings contained in the document. formats() = Array(0, #,##0, $#,##0.--;[RED]-$#,##0.--, ##0,0#\h, ##0,0#\°C, #0,0#\W\h, ##0,0#\k\W\h) Assuming en-US locale settings, ##0,0#\h with the thousands separator character is changed to ##,00#\h in addNew, but not in queryKey. It's the same problem as in issue 38981 and 72380. You should try to use format strings that don't have to be modified. Niklas Thank you very much... Peter, if the macro fails with your locale, let me know and I will write a macro that works around the problem. -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt Info: http://www.pitonyak.org/oo.php -- - To unsubscribe send email to dev-unsubscr...@api.openoffice.org For additional commands send email to sy...@api.openoffice.org with Subject: help
[api-dev] Proper way to find an existing number format style.
(Peter, please test these, but my primary question is directed at the dev mailing list.) Tested on 3.3.0 en-US using the 64-bit Linux version on Fedora 15. I use the following macro to find an existing number format, and I create it if it does not exist. The problem is that oDoc.getNumberFormats().queryKey(sFormat, aLocale, True) fails to find user created numeric formats, it only returns a value for for formats strings contained in the document. Function FindCreateNumberFormatStyle (sFormat As String, Optional doc, Optional locale) Dim oDoc As Object Dim aLocale As New com.sun.star.lang.Locale Dim oFormats As Object Dim formatNum As Integer oDoc = IIf(IsMissing(doc), ThisComponent, doc) oFormats = oDoc.getNumberFormats() If ( Not IsMissing(locale)) Then aLocale = locale End If formatNum = oFormats.queryKey (sFormat, aLocale, True) MsgBox Current Format number for sFormat is formatNum 'If the number format does not exist then add it If (formatNum = -1) Then formatNum = oFormats.addNew(sFormat, aLocale) If (formatNum = -1) Then formatNum = 0 MsgBox New Format number for sFormat is formatNum End If FindCreateNumberFormatStyle = formatNum End Function So, here is my test macro. The first time, the macro runs fine. The second time, the macro fails. Sub TestFormat Dim dummy1$ Dim i As Integer Dim n As Long Dim formats() formats() = Array(0, #,##0, $#,##0.--;[RED]-$#,##0.--, ##0,0#\h, ##0,0#\°C, #0,0#\W\h, ##0,0#\k\W\h) For i = LBound(formats()) To UBound(formats()) n = FindCreateNumberFormatStyle (formats(i)) Next End Sub For certain the macro adds the formats that it fails to find. This macro lists all the formats in the document. Sub ListFormatsInCurrentDocument() Dim oDoc ' Document created to hold the format strings. Dim oFormats ' Formats in the current document. Dim oFormat' Current format object. Dim oData ' Keys queried from the formats. Dim i% ' General index variable. Dim sFormat$ ' Current format string. Dim sPrevFormat$ ' Previous format string. Dim aLocale as new com.sun.star.lang.Locale oFormats = ThisComponent.getNumberFormats() ' Create an output document. oDoc = StarDesktop.loadComponentFromURL( private:factory/swriter, _blank, 0, Array() ) oData = oFormats.queryKeys(com.sun.star.util.NumberFormat.ALL, aLocale, False) For i = LBound(oData) To UBound(oData) oFormat=oFormats.getbykey(oData(i)) sFormat=oFormat.FormatString If sFormatsPrevFormat Then sPrevFormat=sFormat oDoc.getText().insertString(oDoc.getText().End, _ CStr(oData(i)) CHR$(9) sFormat CHR$(10), False) End If Next End Sub Certainly I can first use the quick check and if that fails, then troll the entire list before creating a format, but that just feels silly. Off hand, I do believe that this macro used to work as expected. -- - To unsubscribe send email to dev-unsubscr...@api.openoffice.org For additional commands send email to sy...@api.openoffice.org with Subject: help
[api-dev] Is LineEndName locale dependent?
I use English USA locale. Consider the following Calc macro that sets line starts and line ends based on the name (which I assume is the correct way to do this). Will this work in other languages such as German, French, Russian, Polish, Chinese? Sub InsertLineInCalcDocument Dim oLine Dim oCell1 Dim oCell2 Dim oSheet Dim oPos as new com.sun.star.awt.Point Dim oSize as new com.sun.star.awt.Size Dim oPage oSheet = ThisComponent.Sheets(0) oCell1 = oSheet.getCellByPosition(1, 1) oCell2 = oSheet.getCellByPosition(3, 3) oLine = ThisComponent.createInstance(com.sun.star.drawing.LineShape) oPos.x = oCell1.Position.X oPos.y = oCell1.Position.Y oLine.Position = oPos oSize.Width = oCell2.Position.X - oCell1.Position.X oSize.Height = oCell2.Position.Y - oCell1.Position.Y oLine.Size = oSize oLine.LineWidth = 4 oLine.LineColor = RGB(128, 0, 0) oPage = oSheet.getDrawPage() oPage.add(oLine) REM You must do this AFTER inserting the line into the page. oLine.LineEndName = Arrow oLine.LineStartName = Double Arrow End Sub -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt Info: http://www.pitonyak.org/oo.php -- - To unsubscribe send email to dev-unsubscr...@api.openoffice.org For additional commands send email to sy...@api.openoffice.org with Subject: help
[api-dev] Re: Get list of printers
Excellent! I documented, so it will be in my latest OOME document when I push it out Not nearly sufficient, however. On 04/08/2011 08:53 AM, Bernard Marcelly wrote: I have created Issue http://openoffice.org/bugzilla/show_bug.cgi?id=117769 to request the IDL documentation. Bernard Message de Bernard Marcelly date 2011-04-08 13:47 : Hi, Issue 117765 is good news. But this service com.sun.star.awt.PrinterServer is not documented in the IDL ! Only its interface. I hate using undocumented API. Can it be also corrected ? Regards Bernard Message de Frank Schönheit date 2011-04-08 09:28 : Hi Andrew, I had hoped it would be as easy as CreateUnoService(com.sun.star.awt.PrinterServer) Unfortunately, the returned object is not usable. Usable is a relative term. You can always do something like this: oServer = CreateUnoService(com.sun.star.awt.PrinterServer) oCore = CreateUnoService(com.sun.star.reflection.CoreReflection) oClass = oCore.forName(com.sun.star.awt.XPrinterServer) oMethod = oClass.getMethod(getPrinterNames) aNames = oMethod.invoke(oServer, Array()) Niklas Wow, thanks. Thanks to Ariel, I have a few links, one of which brings me here: http://openoffice.org/projects/api/lists/dev/archive/2008-08/message/66 So this means the problem with this absolutely unusable (despite the CoreReflection hoops) service is known for more than 2.5 years already, and nobody of us developers ever cared? Shame on us! Known as http://openoffice.org/bugzilla/show_bug.cgi?id=117765 now, fixed in CWS fs35a. Ciao Frank -- -- - To unsubscribe send email to dev-unsubscr...@api.openoffice.org For additional commands send email to sy...@api.openoffice.org with Subject: help -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt Info: http://www.pitonyak.org/oo.php -- - To unsubscribe send email to dev-unsubscr...@api.openoffice.org For additional commands send email to sy...@api.openoffice.org with Subject: help
[api-dev] Re: Get list of printers
On 04/07/2011 12:08 PM, Niklas Nebel wrote: On 07.04.2011 15:48, Andrew Douglas Pitonyak wrote: I had hoped it would be as easy as CreateUnoService(com.sun.star.awt.PrinterServer) Unfortunately, the returned object is not usable. Usable is a relative term. You can always do something like this: oServer = CreateUnoService(com.sun.star.awt.PrinterServer) oCore = CreateUnoService(com.sun.star.reflection.CoreReflection) oClass = oCore.forName(com.sun.star.awt.XPrinterServer) oMethod = oClass.getMethod(getPrinterNames) aNames = oMethod.invoke(oServer, Array()) Niklas Wow, thanks. Thanks to Ariel, I have a few links, one of which brings me here: http://openoffice.org/projects/api/lists/dev/archive/2008-08/message/66 Which I assume explains why we need to jump through the hoops mentioned above. I am amazed Never occurred to me that this could be done. Marc, in answer to your question of why, I assume that it is because the type detection stuff is not in place so Basic cannot see the required interface. (or something like that Did not give that comment much thought since my three year old is dragging me off my computer chair). Thanks! -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt Info: http://www.pitonyak.org/oo.php -- - To unsubscribe send email to dev-unsubscr...@api.openoffice.org For additional commands send email to sy...@api.openoffice.org with Subject: help
[api-dev] Re: Load document into a named frame
Thanks. so that has not worked since 1.1. On 03/12/2011 05:23 AM, Oliver Brinzing wrote: Hi Andrew, i just tried your code with oo 1.1.5 and failed - vDoc is null after the second loadComponentFromURL ... so it seems not to work in oo 1.1.5 too ... Regards Oliver -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt Info: http://www.pitonyak.org/oo.php -- - To unsubscribe send email to dev-unsubscr...@api.openoffice.org For additional commands send email to sy...@api.openoffice.org with Subject: help
[api-dev] Load document into a named frame
Should I be able to load a document into a named frame? I last wrote about this with OOo version 1.1 Clearly the behavior has changed, and this no longer seems to work. Consider the following macro that used to work (but no longer does). Sub UseAnExistingFrame Dim noArgs() 'An empty array for the arguments Dim vDoc 'The loaded component Dim sURL As String 'URL of the document to load Dim nSearch As Long 'Search flags Dim sFName As String 'Frame Name Dim vFrame 'Document Frame Dim s As String 'Display string REM Search globally for this nSearch = com.sun.star.frame.FrameSearchFlag.GLOBAL + _ com.sun.star.frame.FrameSearchFlag.CREATE REM I can even open a real file for this, but I don't know what files REM you have on your computer so I create a new Writer document instead sURL = file:///andrew0/home/andy/doc1.odt sURL = private:factory/swriter REM Create a frame with the name MyFrame rather than _default sFName = MyFrame vFrame = ThisComponent.CurrentController.Frame vDoc = vFrame.LoadComponentFromUrl(sURL, sFName, nSearch, noArgs()) If IsNull(vDoc) Then Print Failed to create a document Exit Sub End If REM The name of the frame is MyFrame. Note that the name has nothing REM to do with the title! sFName = vDoc.CurrentController.Frame.Name s = Created document to frame sFName CHR$(10) MsgBox s REM This time, do not allow creation; only allow an existing frame nSearch = com.sun.star.frame.FrameSearchFlag.Global sURL = file:///andrew0/home/andy/doc2.odt sURL = private:factory/scalc sFName = doc1 – OpenOffice.org Writer vDoc = vFrame.LoadComponentFromUrl(sURL, sFName, nSearch, noArgs()) If IsNull(vDoc) Then Print Failed to create a document Exit Sub End If s = s Created document to frame sFName MsgBox s End Sub For those that care, this is the text that is current set to be included with the macro When a component (document) is loaded, it is placed into a frame; the second argument to LoadComponentFromUrl() specifies the name of the frame. If a frame with the specified name already exists, the newly loaded document uses the existing frame. The code in Listing 245 demonstrates the special frame name “_blank”—the special frame names are discussed shortly. Frame names that are not “special,” specify the name of an existing frame or a new frame. If you specify a frame name, you must tell OOo how to find the frame. The values in Table 94 enumerate valid values for the frame search flags. In OOo 1.1.0 I could use a document frame to load a new document into a named frame, but not the desktop frame. In OOo 3.3, both seem to be broken. First, loading a document into a named frame does not name the frame when a new frame is used. So, if I create a new document, the frame name is something like “Untitled 1 – OpenOffice.org Writer”. When I load a document and insist that the correct frame name be used (so a new frame cannot be created) the load only works if the named frame exists, but the document is NOT loaded into that named frame. If you experiment with this, be certain to save your documents before running the macro, at least one experiment caused the new document to load into the current frame. Shall I open a bug report on this? -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt Info: http://www.pitonyak.org/oo.php -- - To unsubscribe send email to dev-unsubscr...@api.openoffice.org For additional commands send email to sy...@api.openoffice.org with Subject: help
Re: [api-dev] problem of determining the location in the document
On 01/28/2011 12:09 PM, Zbigniew Szot wrote: Hi again If i apply my use case (TextSection nested in textTable) to Your snippet. The TextTable property will not be set (will be null) and the textsection property will be set to nested text section. So its dead loop exacly as in my example. I'm working bit too long, and started to have problem with communicating in the clear way. Thanks for taking interest Piter. I hope I've managed to explain where is the catch ;-) Zbyszek On a whim, I spent another couple hours looking at this and I must agree that a solution, if it exists, is tricky at best. Part of the problem is that if you have one object nested in another, then you will likely see both objects. I inserted a section in a section in a table in a section. I can easily walk the parent sections, but, then this totally misses the table. On the other hand, if I check for the table first, then I miss the section. If I walk a sections parents, then I must jump through hoops to find the table (but I can do it). For example, section in a section in a table. I can find the table, but, I must do something a wee bit odd (like create a text cursor). I might be able to find a solution by inspecting the text object in each section, but, that would take way more time than I am willing to invest (since it is not really my problem). This is part of my test code. Sub TraceParent MsgBox TraceParentFromRange(ThisComponent.CurrentCOntroller.ViewCursor, False) End Sub Function TraceParentFromRange(oRangeArg, ignoreTextSection As Boolean) As String If IsNull(oRangeArg) OR IsEmpty(oRangeArg) Then TraceParentFromRange = Exit Function End If Dim oRange oRange = oRangeArg Dim oAnchor Dim s$ Dim sParent$ Dim oSection Dim localIgnoreTextSection As Boolean s = localIgnoreTextSection = False If NOT IsEmpty(oRange.TextSection) AND NOT ignoreTextSection Then localIgnoreTextSection = True oSection = oRange.TextSection Do While NOT IsEmpty(oSection) AND NOT IsNull(oSection) If Len(s) = 0 Then s = TextSection: ' oSection.getName() ' Else s = s Anchored in CHR$(10) TextSection: ' oSection.getName() ' End If oAnchor = oSection.getAnchor() oSection = oSection.getParentSection() Loop 'Inspect oAnchor.getText().createTextCursorByRange(oAnchor) If oAnchor.getText().SupportsService(com.sun.star.text.CellProperties) Then oAnchor = oAnchor.getText().createTextCursor() End If End If If NOT IsEmpty(oRange.Cell) Then If Len(s) 0 Then s = s CHR$(10) End If s = s Cell oRange.Cell.CellName in table oRange.TextTable.getName() oAnchor = oRange.TextTable.getAnchor() End If If s = Then TraceParentFromRange = Root Exit Function End If sParent$ = TraceParentFromRange(oAnchor, localIgnoreTextSection) If Len(sParent) = 0 Then TraceParentFromRange = s Else TraceParentFromRange = s CHR$(10) Anchored in: sParent End If End Function -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt Info: http://www.pitonyak.org/oo.php - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
Re: [api-dev] problem of determining the location in the document
On 01/26/2011 01:53 PM, Zbigniew Szot wrote: Thank you for taking interest in my problem. TextViewCursor/Position is Controller based solution. I would like to stick to model based one. But you brought me an idea, which now seems obvious. I can query XText about supported services. This will give me answer to the question if it is nested. It's not direct answer, but it's good enough ( I hope). Please share any solutions that you find. I see, for example, that if I take a text object from a cell, that this supports cell properties and provides the cell name, but, it does not provide a link to the containing text table. If I create a text cursor from a text object, however, that provides access to the TextTable property. From the text table, you can grab the anchor. My testing stopped there when I managed to crash OOo. Off hand, I expect that you should be able to walk backwards until you finally found the text object for the document. I suppose that it should be mostly obvious how to check for an intersecting text object as it were (as in, where in the tree do they meet). -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt Info: http://www.pitonyak.org/oo.php - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
Re: [api-dev] OpenOffice 3.2.1 not printing on Windows Servers through the API
I really do not understand this. Let me restate the part the confuses me: (1) I can print using a macro with no problem. (2) I cannot print using the API When you use a macro, you use the API; or did I miss something? On 12/18/2010 12:05 PM, Herter, Scott wrote: We have encountered a strange problem that involves OpenOffice 3.2.1 (also reproduced with OpenOffice 2.4 but does not reproduce with OpenOffice 2.1) on Windows Server 2003 R2, 2008, and 2008 R2. The basic problem is that it does not print through the API. The interesting thing is that the same program with the same version of OpenOffice works on Windows XP and Vista. If we run OpenOffice interactively on the Windows Server box and print through the menus or through a Macro it works, but when we try to do it through the API nothing happens. No exception and nothing shows up in the Windows print queue. We are using a Java program to talk to OpenOffice through the UNO API and we have tried both Java 5 and Java 6 with the same results. Convert to PDF, load and close work through the API, just not print. The call to xprintable.print simply returns (type void so there is no return code to check) as if it worked. I changed the code to not close the document after printing and I can press the print button and the document that just failed to print through the API would show up in the print queue. Our current thought is that Microsoft changed something in the security model and maybe we need to do something different with permissions or with the print API under the newer servers. I have done a number of Google searches and checked the API doc to see if something changed with regard to printing, but it looks like we are doing everything correctly and it does work on XP and Vista. If anyone knows of anything we would appreciate some help. On the assumption that no-one has heard of this before these are the steps I will be taking over the next several days to try and isolate the problem further. 1. Create a small stand alone program that reproduces the problem with a test document. 2. Currently the servers are all running as Microsoft HyperV virtual machines whereas the XP and Vista boxes were running native on the hardware. After creating the test program I will run it on a server that is not a virtual machine and see if it still re-creates. 3. Since Macros seem to work I will try and find an API call that lets me run a macro and pass it in parameters to fill in the properties for the print. Thanks. -- I used to think I wasn't a morning person, but things never got better after lunch. -- Wally from Dilbert -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt Info: http://www.pitonyak.org/oo.php - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
[api-dev] list of supported Dispatch commands
I last documented the dispatch commands (meaning I enumerated them) based off of these very outdated links: http://framework.openoffice.org/servlets/ProjectDocumentList http://api.openoffice.org/servlets/ProjectDownloadList http://api.openoffice.org/servlets/ProjectDownloadList?action=downloaddlID=12 Is there a similar list elsewhere? If there is some means to document the currently supported dispatches, I will likely do that (even if it means writing a script to troll the code). It would be even better if I had some way to document the accepted parameters, but, I doubt that I can easily do that. Any help on an existing list, or how to create my own list is appreciated. -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt Info: http://www.pitonyak.org/oo.php - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
Re: [api-dev] Examining a directory with OpenOffice.org Basic
On 12/02/2010 11:10 AM, Johnny Rosenberg wrote: Den 2010-12-02 03:26:53 skrev Andrew Douglas Pitonyak and...@pitonyak.org: There should be an example in this: http://www.pitonyak.org/OOME_3_0.odt http://www.pitonyak.org/AndrewMacro.pdf I searched this one (maybe too quickly) but I didn't find an example that I understood… I'll look again. Consider Listing 151 in OOME_3_0.odt as a starting point. Also, look at table 69 for methods supported by SimpleFileAccess. I have never tested the getFolderContents method, but it is listed as a supported method on a SimpleFileAccess object if you prefer to use that. -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt Info: http://www.pitonyak.org/oo.php - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
Re: [api-dev] Examining a directory with OpenOffice.org Basic
There should be an example in this: http://www.pitonyak.org/OOME_3_0.odt http://www.pitonyak.org/AndrewMacro.pdf On 12/01/2010 08:31 AM, Johnny Rosenberg wrote: If I know the name of a directory, let's say ~/MyImages, how can I easily read the names of all the files in that directory? Let's say that we will fill an array with all the file names. I have searched a bit online, but so far I didn't find anything that I understand… I'll continue searching, though. All kinds of hints are appreciated… Regards Johnny Rosenberg - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt Info: http://www.pitonyak.org/oo.php - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
Re: [api-dev] Attempt for an UNO Undo API
Although I am ignorant in much of this, I do have some random thoughts. Mathias Bauer mentioned allowing the container to control changes for some items (such as he did with notes2), but that this may be a problem with larger objects such as graphics objects and even OLE objects. On the other hand, I do not expect that an OLE object will have any ability to actively participate in the undo process, which forces implementation back to the container (or you simply state that changes made to an OLE object internally are not undoable). For some reason, I keep thinking about the implications of a linked sheet in a Calc document. Now it sounds like two possible interfaces, one controlled by the container and one controlled by the object (that may have an edit engine). There was also talk of throwing multiple types of exceptions when an error occurs. Does this prevent some languages (such as Basic, Perl, and similar) from participating in this scheme? Can/will the undo API affect extensions? Any thoughts on database actions? It does not seem reasonable that a SQL statement will participate, even for an internal Base document, this could be a very long running transaction. -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt Info: http://www.pitonyak.org/oo.php - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
Re: [api-dev] Search with attributes erases text
OK, I guess it is a bug http://qa.openoffice.org/issues/show_bug.cgi?id=114662 On 09/15/2010 11:49 AM, Andrew Douglas Pitonyak wrote: Consider this small program, looks innocent... Find something that matches an attribute (no replacing). Sub SearchTest(oProps()) Dim oFind Dim oFound Dim oDoc oDoc = ThisComponent oFind = oDoc.createSearchDescriptor() With oFind .SearchString = .* .SearchRegularExpression = True .SearchAll = True End With oFind.setSearchAttributes(oProps) oFound = oDoc.FindAll(oFind) print oFound.count for oProps(0).Name End Sub Now, call it as follows: Sub FindCharStyle Dim SearchProps(0) as new com.sun.star.beans.PropertyValue 'Matches everything, and erases everything that it finds. searchProps(0).name = CharStyleName searchProps(0).value = _OOoComputerLiteral searchProps(0).value = xyzzy '??SearchTest(searchProps) 'This finds things as expected searchProps(0).name = CharWeight searchProps(0).value = 100 SearchTest(searchProps) 'Fails searchProps(0).Name = CharFontName searchProps(0).Value = Times New Roman searchProps(0).Value = Albany SearchTest(searchProps) 'Finds stuff, but erases everything that it finds. searchProps(0).Name = CharFontNameAsian searchProps(0).Value = HG Mincho Light J '??SearchTest(searchProps) 'Works searchProps(0).Name = CharFontPitch searchProps(0).Value = 2 SearchTest(searchProps) 'Works searchProps(0).Name = CharNoHyphenation searchProps(0).Value = True SearchTest(searchProps) End Sub Searching on CharStyle name always matches, and then it erases all the text that it finds (well, it replaces it with an empty string). The same for CharFontNameAsian. Searching on CharFontName simply never matches. -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
[api-dev] Search with attributes erases text
Consider this small program, looks innocent... Find something that matches an attribute (no replacing). Sub SearchTest(oProps()) Dim oFind Dim oFound Dim oDoc oDoc = ThisComponent oFind = oDoc.createSearchDescriptor() With oFind .SearchString = .* .SearchRegularExpression = True .SearchAll = True End With oFind.setSearchAttributes(oProps) oFound = oDoc.FindAll(oFind) print oFound.count for oProps(0).Name End Sub Now, call it as follows: Sub FindCharStyle Dim SearchProps(0) as new com.sun.star.beans.PropertyValue 'Matches everything, and erases everything that it finds. searchProps(0).name = CharStyleName searchProps(0).value = _OOoComputerLiteral searchProps(0).value = xyzzy '??SearchTest(searchProps) 'This finds things as expected searchProps(0).name = CharWeight searchProps(0).value = 100 SearchTest(searchProps) 'Fails searchProps(0).Name = CharFontName searchProps(0).Value = Times New Roman searchProps(0).Value = Albany SearchTest(searchProps) 'Finds stuff, but erases everything that it finds. searchProps(0).Name = CharFontNameAsian searchProps(0).Value = HG Mincho Light J '??SearchTest(searchProps) 'Works searchProps(0).Name = CharFontPitch searchProps(0).Value = 2 SearchTest(searchProps) 'Works searchProps(0).Name = CharNoHyphenation searchProps(0).Value = True SearchTest(searchProps) End Sub Searching on CharStyle name always matches, and then it erases all the text that it finds (well, it replaces it with an empty string). The same for CharFontNameAsian. Searching on CharFontName simply never matches. -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
[api-dev] OOo users at Linux Fest in Columbus Ohio
OK, so who is attending Linux Fest in Columbus Ohio this year? http://ohiolinux.org/ September 10 - 12 I, Andrew Pitonyak will be there. Drew Jensen (the Base GURU) will be there Jason Corfy (OOo Forum Moderator) will be there Seems like an opportunity for us OOo folks to get together Friday night, Saturday night, or something similar. Historically, Jason and I have gone to lunch on Saturday at BD Mongolian Grill (you pick your food and spices then they cook it for you). http://www.gomongo.com/ http://www.gomongo.com/locations/locationDetails.php?loc=25 bd's mongolian barbeque 295 Marconi Blvd. Columbus OH 43215 (614) 586-0077 If there is sufficient interest, I will attempt to setup something else as well (Like Friday and/or Saturday dinner). I will probably try to include my wife and two young daughters (I like spending time with them, what can I say), which may mean a kid friendly location, or simply having people swing by my place (since I live about 10 minutes from downtown). So, who is interested? I can provide my cell phone for people worried about being lost. -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
Re: [api-dev] Searching for a Document Property - Writer
On 08/08/2010 08:52 AM, Thomas Krumbein wrote: Hey Bernard, Bernard Marcelly schrieb: Message de Thomas Krumbein date 2010-08-04 11:24 : Hey, By one of my customer we have a problem during migration to OOo 3.2.1: The page-layout is different and this is dramaticly because the page break in now one line prior - and a lot of document didn´1 work as expected. Analysing the problem it depend on a different setting in the option menu: in tools - options - OOo writer - compatibility the first checkbox (in German Druckermaße für Dokumentformatierung verwenden) is not set any more. Unfortunatly when I open a existing document via macro this checkbox is marked - so the information musst be stored anywhere in the document. But I do not know where??? Any hints? I will try to change the setting per basicmacro after insert such a document. Thanks in advance, Thomas Hi Thomas, It is more exactly the equivalent check in the printer dialog box, Options... Dim ds As Object ds = ThisComponent.createInstance(com.sun.star.text.DocumentSettings) ds.PrintPaperFromSetup = False Hmm, no - this was the wrong property. I have now checked the settings.xml and have searched for different values - the searched property is: PrinterIndependentLayout I can set a value using basic as you mentioned - that works. But: Even using xray I cannot find the property anywhere in the document. Maybe you have an idea? Because - before I set this property I would like to check the actual value - if this property is active (property is optional). But how to du this??? Best regards Thomas Probably this: PrinterIndependentLayout http://api.openoffice.org/docs/common/ref/com/sun/star/document/PrinterIndependentLayout.html For me, I think that 1 is enabled and 3 is disabled. -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
Re: [api-dev] Please verify bug in StarBasic Format command
On 06/26/2010 03:37 AM, Johnny Rosenberg wrote: 2010/6/26 Andrew Douglas Pitonyakand...@pitonyak.org: d// h:nn:ss = nn produces the expected output from ddd, namely the three letter day name. Same happens for me, except that day name is two letters (in Swedish): d// h:nn:ss = 26-juni-2010 9:lö:46 (lö=lördag=saturday) d// h:dd:ss = dd produces the two digit minute, which I expected with nn. I get the correct output in this case: dd = 26 nn = 24 d// h:dd:ss = 26-juni-2010 9:26:46 You are correct, glad you caught that. that should not have slipped by me :-) I'm on Ubuntu 10.04 but I uninstalled the Ubuntu version (since it had a bug that I couldn't live with) and installed the ”vanilla” version instead: OOO320m12 (Build:9483). My computer is old (bought in the end of 2006) so everything is 32-bit. Johnny Rosenberg Thanks Johnny! http://qa.openoffice.org/issues/show_bug.cgi?id=112722 -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
[api-dev] Please verify bug in StarBasic Format command
I see errors in the 64-bit Linux release with this simple macro Sub strangeFormats Dim i% Dim d As Date d = now() Dim s$ Dim formats formats = Array(q, y, yy, , _ m, mm, mmm, , _ d, dd, ddd, , d, dd, _ w, ww, h, hh, n, nn, s, ss, _ t, c, _ d// h:dd:ss, d// h:nn:ss) For i = LBound(formats) To UBound(formats) s = s formats(i) = Format(d, formats(i)) CHR$(10) Next MsgBox s End Sub What I see (correctly): dd = Two digit day nn = two digit minute Incorrect: d// h:nn:ss = nn produces the expected output from ddd, namely the three letter day name. d// h:dd:ss = dd produces the two digit minute, which I expected with nn. Just want to know how to file the bug! -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
[api-dev] Please verify wrong behavior with CDateFromISO
I verified strange behavior with CDateFromISO years ago. I am testing again, and I am trying to figure out if the problem is related to 64-bits (my version) as opposed to a 32-bit version. What is the output from the following two commands? I understand the strange value in the second line, but, late time I ran the first line, I received 03/14/1432 (This assumes USA, but other Locale is OK for this test). Print CDateFromISO(14320313) ' 03/04/1432 Print CDateFromISO(18991230) '00:00:00 -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
Re: [api-dev] Please verify wrong behavior with CDateFromISO
On 06/19/2010 02:35 AM, Andrew Douglas Pitonyak wrote: I verified strange behavior with CDateFromISO years ago. I am testing again, and I am trying to figure out if the problem is related to 64-bits (my version) as opposed to a 32-bit version. What is the output from the following two commands? I understand the strange value in the second line, but, late time I ran the first line, I received 03/14/1432 (This assumes USA, but other Locale is OK for this test). Print CDateFromISO(14320313) ' 03/04/1432 Print CDateFromISO(18991230) '00:00:00 OK, I got it. This appears to be a bug fix... The ISO standard requires that dates be continuous. The current behavior is correct. I did not bother to verify if the behavior changed for the ISO standard in 2004. -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
[api-dev] com.sun.star.util.TextSearch does not support documented options.
http://qa.openoffice.org/issues/show_bug.cgi?id=112431 http://www.oooforum.org/forum/viewtopic.phtml?t=101554postdays=0postorder=ascstart=0 To use the com.sun.star.util.TextSearch service for a case-insensitive search, the search options state that ALL_IGNORE_CASE is deprecated and that TransliterationModulesNew should be used. See: http://api.openoffice.org/docs/common/ref/com/sun/star/util/SearchFlags.html First, note that TransliterationModules has a constant for IGNORE_CASE that works, but, the document specifically names another set of constants. http://api.openoffice.org/docs/common/ref/com/sun/star/i18n/TransliterationModules.html You can see the new constants here: http://api.openoffice.org/docs/common/ref/com/sun/star/i18n/TransliterationModulesNew.html If I use these constants, I can use UPPERCASE_LOWERCASE or LOWERCASE_UPPERCASE with no problem. I am not, however, able to use IGNORE_CASE while setting the transliteration flags. I expect the following macro to find both aaa and AAA Sub StringTextSearch Dim oTextSearch ' TextSearch service Dim sStrToSearch As String' String to serach Dim sMatchString As String' String that was found Dim aSearchResult ' http://api.openoffice.org/docs/common/ref/com/sun/star/util/SearchResult.html Dim rank As Long Dim iMatchStartPos As Long Dim iMatchLen As Long Dim aSrcOpt As New com.sun.star.util.SearchOptions Dim s$ Dim enLocale As New com.sun.star.lang.Locale enLocale.Language = en enLocale.Country = US oTextSearch = CreateUnoService(com.sun.star.util.TextSearch) s = With aSrcOpt 'http://api.openoffice.org/docs/common/ref/com/sun/star/util/SearchFlags.html .searchFlag = com.sun.star.util.SearchFlags.REG_EXTENDED .Locale = enLocale 'Supports ABSOLUTE, REGEXP, and APPROXIMATE .algorithmType = com.sun.star.util.SearchAlgorithms.REGEXP .searchString = a+ 'This does not work. .transliterateFlags = com.sun.star.i18n.TransliterationModulesNew.IGNORE_CASE 'This works '.transliterateFlags = com.sun.star.i18n.TransliterationModulesNew.UPPERCASE_LOWERCASE End With oTextSearch.setOptions(aSrcOpt) sStrToSearch = aaa hello AAA aSearchResult = oTextSearch.searchForward(sStrToSearch, 0,Len(sStrToSearch)-1 ) 'Print aSearchResult.subRegExpressions REM subRegExpressions has value zero if no match... Do While aSearchResult.subRegExpressions 0 'Print + LBound(aSearchResult.startOffset) + : + UBound(aSearchResult.startOffset) rank = aSearchResult.subRegExpressions - 1 iMatchStartPos = aSearchResult.startOffset(rank) + 1 iMatchLen = aSearchResult.endOffset(rank) - aSearchResult.startOffset(rank) sMatchString = Mid(sStrToSearch, iMatchStartPos, iMatchLen) s = s ( + LBound(aSearchResult.startOffset) : + UBound(aSearchResult.startOffset) ) =sMatchString CHR$(10) aSearchResult = oTextSearch.searchForward(sStrToSearch, aSearchResult.endOffset(rank)+1,Len(sStrToSearch)-1 ) Loop MsgBox s End Sub -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
Re: [api-dev] DEV300m78 Breaks enableasync property
On 05/31/2010 03:22 AM, Stephan Bergmann wrote: On 05/30/10 19:04, Andrew Douglas Pitonyak wrote: The following line of code has worked for some time, including the current production build. I have not checked it against the latest release candidate: oConfigProvider = GetProcessServiceManager().createInstanceWithArguments(_ com.sun.star.configuration.ConfigurationProvider,_ Array( CreateProperty( enableasync, bEnableSync ) ) ) This line of code fails in DEV300m78, which is the development branch for 3.3 I believe. Message: com.sun.star.configuration.ConfigurationProvider factory: unknown argument enableasync. This affects configuration code that I have in my code colorizer http://extensions.services.openoffice.org/project/CodeFormatter Shall I open a bug against this? That got lost with the configmgr re-write of http://qa.openoffice.org/issues/show_bug.cgi?id=101955, integrated in DEV300_m74. Please file me (sb) an issue to accept that property again. -Stephan Thanks, created and assigned to you. http://qa.openoffice.org/issues/show_bug.cgi?id=111970 -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
[api-dev] DEV300m78 Breaks enableasync property
The following line of code has worked for some time, including the current production build. I have not checked it against the latest release candidate: oConfigProvider = GetProcessServiceManager().createInstanceWithArguments(_ com.sun.star.configuration.ConfigurationProvider,_ Array( CreateProperty( enableasync, bEnableSync ) ) ) This line of code fails in DEV300m78, which is the development branch for 3.3 I believe. Message: com.sun.star.configuration.ConfigurationProvider factory: unknown argument enableasync. This affects configuration code that I have in my code colorizer http://extensions.services.openoffice.org/project/CodeFormatter Shall I open a bug against this? Sad that I still cannot open AndrewMacro.odt without crashing OOo in 3.3 sigh http://qa.openoffice.org/issues/show_bug.cgi?id=84159 -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
[api-dev] Sending email to multiple recipients
When I looked at the service definitions, I thought that I should be able to send an email message to multiple people at one time. The setCCRecipient, for example, accepts a list of email addresses. Only the first address is used. I tested on Linux using Thunderbird. Does this seem correct? Shall I open a bug against this? Sub SendSimpleMail_multiple() Dim vMailSystem, vMail, vMessage vMailSystem = createUnoService( com.sun.star.system.SimpleCommandMail ) 'vMailSystem=createUnoService(com.sun.star.system.SimpleSystemMail) vMail=vMailSystem.querySimpleMailClient() vMessage = vMail.createSimplemailMessage() vMessage.SetRecipient(jashmore@teamcertified.com) vMessage.setCCRecipient(Array(and...@pitonyak.org, te...@pitonyak.org)) vMessage.setBCCRecipient(Array(te...@pitonyak.org, te...@pitonyak.org)) vMessage.setsubject(Test Message from and...@pitonyak.org) vMail.sendSimpleMailMessage(vMessage, _ com.sun.star.system.SimpleMailClientFlags.NO_USER_INTERFACE) End Sub -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
Re: [api-dev] Sharing macros with people…
Mr. Rosenberg, Sorry for the late reply, but I have been very busy. Have you seen the Extension Compiler by Bernard Marcelly? I used this to create my code colorizer, that is able to colorize things such as Java, C++, C#, Java, Perl, and XML http://extensions.services.openoffice.org/project/CodeFormatter If you have trouble with the Extension Compiler, you can take a look at the configuration and directory structure that I use (I am willing to tar / zip it and send you the raw files used to create it). Let me know... On 12/20/2009 12:19 PM, Johnny Rosenberg wrote: Anyone who can point me to somewhere where I can learn to create an add-on or extension? My thought is that the person to whom I send it should easily install it by the extension manager, so I guess I need to create an OXT somehow. How is all that done properly? Johnny Rosenberg -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
Re: [api-dev] OpenOffice.org Basic - Sear ch and Replace in code…
On 10/28/2009 12:32 PM, Johnny Rosenberg wrote: 2009/10/28 Jan Holst Jensenj...@biochemfusion.com: Andrew Douglas Pitonyak wrote: You should post your code... On 10/24/2009 06:05 AM, Johnny Rosenberg wrote: One example: Search for: ([a-zA-Z0-9\(\)])([\+|\-|\*|\/])([a-zA-Z0-9\(\)]) Replace with: $1 $2 $3 I tried this in OpenOffice.org Writer and it works perfectly. Before: a+b hej(3)+svejs(4) tjoho(x)+3 After: a + b hej(3) + svejs(4) tjoho(x) + 3 Doing the same thing in OpenOffice.org Basic: Before: a+b hej(3)+svejs(4) tjoho(x)+3 After: $1 $2 $3 hej(3$1 $2 $3vejs(4) tjoho(x$1 $2 $3 Doesn't look very nice to me… Is this a bug or am I not supposed to do this? I believe that is exactly what Johnny did. I can reproduce it from the above. Writer reformats the text in a document so the spacing is nicer. In the Basic code editor the replace action inserts $1 $2 $3 which is pretty useless. At least I can conclude that regular expression search/replace works differently in a Writer text document and in the Basic editor. Cheers -- Jan I think that Andrew maybe misunderstood me a bit there, and that you then misunderstood him, but maybe I am wrong. Just in case I am right, I will just point out that I use the ordinary Ctrl+F search in my code to replace things. I did NOT write a Search Replace macro of my own or anything like that. All I wanted to do was to make my code look more consistent, making sure that spaces and things like that are used the same way in all code of the project, making it easier to read and nicer to look at… So there is no point to post any kind of code, since the same thing happens for any kind of text, for example the text I used in my examples in my original post. Johnny Rosenberg Oh my, yes, I thought that I was reading the dev forum, and I thought that this was only with respect to a macro. sigh Sorry -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
Re: [api-dev] OpenOffice.org Basic - Sear ch and Replace in code…
You should post your code... On 10/24/2009 06:05 AM, Johnny Rosenberg wrote: I am coding something in OpenOffice.org Calc using the built in Basic language thing. Now, when I produced about 50 KiB of code I found that I was not very consistent in how to type things. For example, sometimes I type like ”BlahBlah=Foo+Bar-3” and sometimes like ”BlahBlah=Foo + Bar - 3”. So I figured that it wouldn't be too hard to search for patterns using regular expressions for replacing things, but I failed doing this! Thing like work perfectly in OpenOffice.org Writer Search and Replace doesn't seem to work at OpenOffice.org Basic Search and Replace. One thing that I need to do this, I guess, is things like $1, $2 and things like that in the Replace field, but all happens is that my search string is replaces by $1 and $2 respectively. Of course the Regular Expression checkbox is ticked. One example: Search for: ([a-zA-Z0-9\(\)])([\+|\-|\*|\/])([a-zA-Z0-9\(\)]) Replace with: $1 $2 $3 I tried this in OpenOffice.org Writer and it works perfectly. Before: a+b hej(3)+svejs(4) tjoho(x)+3 After: a + b hej(3) + svejs(4) tjoho(x) + 3 Doing the same thing in OpenOffice.org Basic: Before: a+b hej(3)+svejs(4) tjoho(x)+3 After: $1 $2 $3 hej(3$1 $2 $3vejs(4) tjoho(x$1 $2 $3 Doesn't look very nice to me… Is this a bug or am I not supposed to do this? Johnny Rosenberg - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
Re: [api-dev] OOo BASIC - Somewhat tricky arrays…
You are correct, array assignment sets the new array to reference the old array. This is also the case with many of the UNO components. You will find to your dismay, that there are a few structures that do not assign this way. I do not remember many examples off hand, but things such as table borders and perhaps image size come to mind. I think that I discuss this here: http://www.pitonyak.org/oooconf/OOoConf_2004_Macro_Presentation.sxi -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
Re: [api-dev] Progress on exporting the Dev Guide to ODT and PDF
On 09/09/2009 07:36 AM, Ariel Constenla-Haile wrote: Hello Andrew, On Sunday 06 September 2009, 14:40, Andrew Douglas Pitonyak wrote: Exporting the existing syntax highlighting from the Wiki is beyond the current capabilities of the Book (Collection) extension. If anyone has any ideas on how this might be done... I'm definitely open to them :-) I have macros that do something similar in OOo. I apply character styles to different portions of the text to colorize them. The primary macro works based on a cursor selection. I have code that wades through an entire document and color codes what it finds based on paragraph styles. Because I am not aware of your process, I do not know how adaptable this is for your export process. I maintain the latest copy here: http://extensions.services.openoffice.org/project/CodeFormatter applying the code formatter to a huge document like the Developer's Guide seems impossible due to issue http://qa.openoffice.org/issues/show_bug.cgi?id=84159 Regards Yes, AndrewMacro.odt now causes OOo to crash when the document is closed. I would go even further, however, and state that a large document such as the developer's guide could cause OOo to crash even without colorizing the examples because of this bug. -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
Re: [api-dev] Progress on exporting the Dev Guide to ODT and PDF
On 09/05/2009 09:04 AM, Clayton wrote: Maybe one suggestion (very nice to have): would it be possible to apply syntax coloring/highlighting to the example code? It would make it so much easier for readers to orientate themselves in the code examples. Something like applying the [g]vim syntax highlighting? Would you be able/contemplate of adding it? Hmmm... I'm not sure how easy this will be. The code blocks are given a Preformatted paragraph style which applies the grey background, and the monospaced character styles. Short of manually editing and applying custom character styles through all code blocks, I'm not sure how it could be done. Exporting the existing syntax highlighting from the Wiki is beyond the current capabilities of the Book (Collection) extension. If anyone has any ideas on how this might be done... I'm definitely open to them :-) I have macros that do something similar in OOo. I apply character styles to different portions of the text to colorize them. The primary macro works based on a cursor selection. I have code that wades through an entire document and color codes what it finds based on paragraph styles. Because I am not aware of your process, I do not know how adaptable this is for your export process. I have code that can colorize starbasic, Java, C++, Perl, Python, and XML. I use simplistic parsers, but the only error of which I am currently aware (that I have not yet fixed) is that in Basic, I failed to list \ as an operator (integer division). Oops! That might work. The ODFs use a paragraph style for all of the code blocks in the main text. It can't hurt to give it a try - the ODFs are all available on the Wiki Books page. The export process uses the Collection/Book export to ODT, and from there I simply import a template to it, tidy up a few places where the template doesn't yet work quite right and publish. The macro, if it works, could be rolled into the template for future publish runs. C. I maintain the latest copy here: http://extensions.services.openoffice.org/project/CodeFormatter The code is open for use in any way you desire, with a request (not an insistence) to know of bugs, changes, what ever. In its current state, a line is considered a single paragraph, not a new line character. This is of most importance when a comment is found, because the rest of the line is marked as a comment. The algorithm is not perfect, but it is small. For example, a Print method on an object will be colorized as a key word (as in x.print()). -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
Re: [api-dev] Insert a cross reference to a heading
On 09/01/2009 05:06 PM, Andrew Douglas Pitonyak wrote: How can I use a macro to insert a cross reference to a specific header? Based on the lack of response, I assume that it is not known or not possible. If anyone cares, I added a new section to my document with an investigation, on this topic (section 7.29 if I remember correctly). A summary is as follows: When you add a cross reference to a header, a bookmark is created around that header. You do not have access the bookmark through the standard methods such as getBookmarks, but you can find where it is set by enumerating through the text (I provide code that does exactly this). Although I did not provide to demonstrate the process, you can likely create a reference to this hidden bookmark. Also, although you likely do not have access to the code that will create these hidden bookmarks, you can always create your own bookmarks around headings and use those if you so desire. -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
Re: [api-dev] Progress on exporting the Dev Guide to ODT and PDF
On 08/21/2009 10:12 AM, Clayton wrote: I am also combining the chapters into one single document. So far, Chapters 1 to 6 are in one doc, and can also be downloaded from the page linked above. Maybe one suggestion (very nice to have): would it be possible to apply syntax coloring/highlighting to the example code? It would make it so much easier for readers to orientate themselves in the code examples. Something like applying the [g]vim syntax highlighting? Would you be able/contemplate of adding it? Hmmm... I'm not sure how easy this will be. The code blocks are given a Preformatted paragraph style which applies the grey background, and the monospaced character styles. Short of manually editing and applying custom character styles through all code blocks, I'm not sure how it could be done. Exporting the existing syntax highlighting from the Wiki is beyond the current capabilities of the Book (Collection) extension. If anyone has any ideas on how this might be done... I'm definitely open to them :-) C. I have macros that do something similar in OOo. I apply character styles to different portions of the text to colorize them. The primary macro works based on a cursor selection. I have code that wades through an entire document and color codes what it finds based on paragraph styles. Because I am not aware of your process, I do not know how adaptable this is for your export process. I have code that can colorize starbasic, Java, C++, Perl, Python, and XML. I use simplistic parsers, but the only error of which I am currently aware (that I have not yet fixed) is that in Basic, I failed to list \ as an operator (integer division). Oops! -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
Re: [api-dev] Declare fields in a structure
On 08/22/2009 04:31 PM, sphiller wrote: I'm starting to convert a large VBA project into OOBasic, and it mostly looks straightforward; however, i've hit a stumbling block because I have a number of structures declared with arrays in them, and the OO compiler says I can't have arrays inside of structs. So I'm not at all sure how to work around this. For example, I have these structures: Type FieldPairType fieldName As String fieldValue As String End Type Type FieldsListType fieldCnt As Integer fieldsAllocated As Integer fields() As FieldPairType End Type And I dynamically resize (ReDim) the fields array as required when working with this type. The compiler won't allow me to declare fields() inside the structure. There's got to be a way around this, but I don't see it yet. I guess i can turn FieldPairType into a class and then make fields a linked list of objects, but I've got more than a few structures that work this way, and that means a lot of extra work. Is there an easier way to handle a dynamically sized 'array' of values inside a structure in OO Basic? Have you tried using a variant type and assigning an array to it? I do not know if this will work or not. i think that I tried this some years back, but I do not remember the outcome. -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
Re: [api-dev] Get last used column/row in a spreadsheet (Macro)
Nice tip... I will change this in my document... I have no idea why this is written as it is, but many of the snippets were created years ago with OOo 1.x, so, the issue may be that the author of that particular macro (probably me) was not properly efficient, or, that OOo did not support the methodology. In this case, I suspect the first. On 08/30/2009 08:54 AM, Johnny Rosenberg wrote: At page 142 in the macro manual by A. Pitonyak, there is a section about how to do it, here's a function that returns the last column of the used area: Function getLastUsedColumn(oSheet as Object) as Integer Dim oCell As Object Dim oCursor As Object Dim aAddress As Variant oCell = oSheet.GetCellbyPosition( 0, 0 ) oCursor = oSheet.createCursorByRange(oCell) oCursor.GotoEndOfUsedArea(True) aAddress = oCursor.RangeAddress GetLastUsedColumn = aAddress.EndColumn End Function I am wondering about the oCell thing. Why is that necessary? I tried the following and it seems to work: Function getLastUsedColumn(oSheet as Object) as Integer Dim oCursor As Object Dim aAddress As Variant oCursor = oSheet.createCursor oCursor.GotoEndOfUsedArea(True) aAddress = oCursor.RangeAddress GetLastUsedColumn = aAddress.EndColumn End Function Or even shorter, and still works and just as easy to follow (in my opinion): Function getLastUsedColumn(oSheet as Object) as Integer Dim oCursor As Object oCursor = oSheet.createCursor oCursor.GotoEndOfUsedArea(True) GetLastUsedColumn = oCursor.RangeAddress.EndColumn End Function Johnny Rosenberg - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
[api-dev] Insert a cross reference to a heading
How can I use a macro to insert a cross reference to a specific header? -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
[api-dev] setData on a chart
I received a request on how to set the data on a chart. Calling setData causes OOo to crash, and it used to work. This appears to be a regression problem, because the macro used to work. First, the original question as posed to me: On 07/28/2009 11:11 AM, BD RJ wrote: In OpenOffice.org Basic for Calc documents there was the method *setData()* for charts, that made us able to assign chart's data from an array. We can find an example of code with this istruction in OpenOffice wiki at the link: http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Charts/Data_Access Code lines in question are after the explanation of the XChartDataArray interface. We can analize this interface at the link: http://api.openoffice.org/docs/common/ref/com/sun/star/chart/XChartDataArray.html ** The method *setData() *belong to this inteface and his parameter and description are in the last link. The problem is: In the last version of OpenOffice (OpenOffice 3.x) this istruction make OpenOffice crash. ** I have also explained my problem in http://www.oooforum.org/forum/viewtopic.phtml?p=334655 but noone answered me. Can you please help me? Thanks in advance The original macro that used to work is as follows: Sub GR oDoc = ThisComponent oCurSheet = oDoc.CurrentController.ActiveSheet oCharts = oCurSheet.Charts Dim aRect as new com.sun.star.awt.Rectangle oCharts.addNewByName(chart1, aRect, Array(), False, True) oChart = oCharts.getByName(chart1).EmbeddedObject Dim oData as Object Dim oDataArray(0 To 1) as Object Dim oX(0 To 2) As Double Dim oY(0 To 2) As Double oX(0) = 4.5 oX(1) = 2.6 oX(2) = 17.0 oY(0) = 45.0 oY(1) = 23.0 oY(2) = 11.0 oDataArray(0) = oX() oDataArray(1) = oY() oChart.Diagram.DataRowSource = com.sun.star.chart.ChartDataRowSource.ROWS oData = oChart.Data oData.setData(oDataArray()) End sub This fails when the data is set. I even tried a close approximation: Sub GR Dim oDoc, oCurSheet, oCharts, oChart Dim oDiagram, oChartDoc oDoc = ThisComponent oCurSheet = oDoc.CurrentController.ActiveSheet oCharts = oCurSheet.Charts Dim oRect ' If (oCharts.hasByName(chart1)) Then ' Inspect oCharts ' Exit Sub ' End If oRect = createObject(com.sun.star.awt.Rectangle) oRect.X = 1 oRect.Y = 1000 oRect.width = 1 oRect.Height= 1 oCharts.addNewByName(chart1, oRect, Array(), False, True) oChart = oCharts.getByName(chart1) Dim oData as Object Dim oDataArray(0 To 1) as Object Dim oX(0 To 2) As Double Dim oY(0 To 2) As Double oX(0) = 4.5 oX(1) = 2.6 oX(2) = 17.0 oY(0) = 45.0 oY(1) = 23.0 oY(2) = 11.0 oDataArray(0) = oX() oDataArray(1) = oY() oChartDoc = oChart.getEmbeddedObject() oDiagram = oChartDoc.createInstance( com.sun.star.chart.LineDiagram ) oChartDoc.setDiagram( oDiagram ) oDiagram = oChartDoc.getDiagram() oDiagram.DataRowSource = com.sun.star.chart.ChartDataRowSource.ROWS oData = oChartDoc.Data ' Inspect oData oData.setData(oDataArray()) End sub -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html
Re: [api-dev] Focus window to the view cursor
Interesting, thanks for the reply... That had not occurred to me On 07/02/2009 02:20 AM, Christoph Jopp wrote: Hi Andrew, tried to reproduce this behaviour and found following: When I started the macro from within the macro-editor it's just as you said. When I started from within the writer document the view adjusts Maybe that helps for further investigation Christoph I move the view cursor in a Write document and then the cursor is no longer visible. What is the trick to move the view so that I can see the view cursor. If I manually press a key to move the cursor, then the view changes so that I can see the cursor. I just cannot remember how to do this from StarBasic. -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
[api-dev] Focus window to the view cursor
I move the view cursor in a Write document and then the cursor is no longer visible. What is the trick to move the view so that I can see the view cursor. If I manually press a key to move the cursor, then the view changes so that I can see the cursor. I just cannot remember how to do this from StarBasic. -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
Re: [api-dev] How to find the Default paragraph style
Thanks Bernard... I will change my code to use the display name rather than the internal name. Bernard Marcelly wrote: Hi Andrew, A style has an internal name and a localized display name. A custom style has the same internal name and display name. snip -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
[api-dev] How to find the Default paragraph style
I want to know the name of the Default paragraph style. I would also like to find the Default paragraph style. I am using en language in the USA. Consider code such as the following: oStyles = oDoc.StyleFamilies.getByName(ParagraphStyles) sss = Default sss = Standard If oStyles.hasByName(sss) Then Print is the name sss = oStyles.getByName(sss).Name End If This prints: is the name Default = Standard OK, so the the GUI uses the name Default, the container is able to find a style named Default, but the returned style is really named Standard. If I check the names, it says Standard, not Default. How do I find the name of the Default paragraph style? My inclination is to use oStyles.getByIndex(0) -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
Re: [api-dev] Unfortunate document event name - how to fix it?
Mathias Bauer wrote: (*) I hope that I could make clear that the reason for my event name change is not elegance, I really consider the current name confusing. But as I accept the backward compatibility burden, this point now is moot anyway. I have chatted with numerous people that incorrectly used the event in question based on its name (including me). -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
Re: [api-dev] Impress text shape/frame
I don't think that you can use a text cursor in an Impress document. Serguei Vdovine wrote: Hello, I failed to change the text content of a selected text shape(shaded box around text and cursor) on a Impress 3.0 slide with Sub testGetSelect oDoc = ThisComponent() oDocCtrl = oDoc.getCurrentController() IF (not isEmpty(oDocCtrl.getSelection())) then oSelection = oDocCtrl.getSelection() oSel = oSelection.getByIndex(0) xTextCursor=oSel.createTextCursor() xTextCursor.gotoEnd(False) oSel.insertString(xTextCursor, Hello, false) else MsgBox(no selection) end if End Sub What might be wrong? Thanks a lot in advance, Serguei -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
Re: [api-dev] Regresion in User Defined DocumentInfo
Frank Schönheit - Sun Microsystems Germany wrote: Hi Fernand, now i have to use oDocuInfo.GetpropertieValue( PMG_StylesVakjes) Changing this few lines is not the problem, but The code is around in Thousands of documents :-) should i start changing my code or can this be fixed ? I'd say this is an API compatibility issue. Try submitting a issue, and raising it as 3.1 blocker in relea...@openoffice.org (1) I believe that the document information object is deprecated in favor of document properties. You may want to consider finding a solution that works with document properties instead. (2) The fact that the document information object still exists, I would have expected it to continue to function as before (so this feels like a bug to me). -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
Re: [api-dev] I need basic examples of StarBasic macros for Ubuntu database programming with FORMS
Find and download AndrewBase.odt Peter Belmont wrote: I need basic examples of StarBasic macros for Ubuntu database programming with FORMS PLEASE CC any responses to me. Thanks. Examples of basic code that would be welcome: [1] counting the CONTROLs on the form (on EVENT from one of them) [2] getting their NAMEs [3] getting their current values [4] setting a value [5] getting a LISTBOX to re-initialize w/o exiting the entire form-execution -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
[api-dev] How to make a Python macro visible to OOo?
It is possible to write a macro in Python. Use Tools - Macros - Organize Macros - Python to view the Python macros included with OOo. I am told that this worked fine in OOo 2.4, but when I tried this in OOo 3.0, I could not figure out how to make this work apart from directly placing the macros with the samples distributed with OOo. -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
[api-dev] Finding Formula objects in a Write document
How can I find a Formula object in a paragraph? I can enumerate the embedded objects in the document as follows: Sub LookAtEmbeddedObjects Dim oDoc Dim oEmbed Dim oObj Dim i As Integer Dim s As String oDoc = ThisComponent oEmbed = oDoc.getEmbeddedObjects() s = For i = 0 To oEmbed.getCount()-1 oObj = oEmbed.getByIndex(i) If oObj.supportsService(com.sun.star.text.TextEmbeddedObject) Then If oObj.CLSID = 078B7ABA-54FC-457F-8551-6147e776a997 Then s = s oObj.getEmbeddedObject().Formula CHR$(10) End If End If Next MsgBox s End Sub I used a simple enumeration of the text object, and I even found the text section containing the formula. I only know this, however, because I used a very simple document with simple text and a formula (or two). The enumeration starts as follows: oParEnum = oDoc.getText().createEnumeration() Do While oParEnum.hasMoreElements() oPar = oParEnum.nextElement() If oPar.supportsService(com.sun.star.text.Paragraph) Then oEnum = oPar.createEnumeration() Do While oEnum.hasMoreElements() oSect = oEnum.nextElement() I can perform comparisons such as: If oSect.supportsService(com.sun.star.text.TextField) Then or even If NOT IsNull(oSect.Bookmark) Then If I call getString() on the section, it returns an empty string, and the text content type appears to be Frame, which I did not expect. -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
Re: [api-dev] Finding Formula objects in a Write document
Bernard Marcelly wrote: Message de Andrew Douglas Pitonyak date 2009-02-03 16:50 : How can I find a Formula object in a paragraph? I used a simple enumeration of the text object, and I even found the text section containing the formula. I only know this, however, because I used a very simple document with simple text and a formula (or two). The enumeration starts as follows: oParEnum = oDoc.getText().createEnumeration() Do While oParEnum.hasMoreElements() oPar = oParEnum.nextElement() If oPar.supportsService(com.sun.star.text.Paragraph) Then oEnum = oPar.createEnumeration() Do While oEnum.hasMoreElements() oSect = oEnum.nextElement() I found the formulas with yet another enumeration: if oSect.supportsService(com.sun.star.text.TextPortion) Then if oSect.TextPortionType = Frame then oTcEnu = oSect.createContentEnumeration(com.sun.star.formula.FormulaProperties) Do While oTcEnu.hasMoreElements() oTc = oTcEnu.nextElement() oTc is the embedded formula object. Regards Bernard OK, so I needed to enumerate one more time into the text content to obtain the formulas. I thought that I could obtain the formulas using enumeration (if appropriately anchored), but I was not certain. Thanks Bernard! -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
Re: [api-dev] Java: insert DOC into a new Impress document?
Can you do this from the GUI? I tried and failed. My point is just that if you can not do this from the GUI, then you probably can not do this using the API (not always true, but...) Albert Law wrote: Hi, I was wondering how to insert a DOC file into a new Impress document. I'm at the point where I have created the new Impress document, made an XShape, and inserted the XShape. But I have no idea how to set the XShape to contain my DOC file which I have loaded into an XComponent. I've been playing around with: XPropertySet xPropertySetShape = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xShape); xPropertySetShape.setPropertyValue(CSLID, 12dcae26-281f-416f-a234-c3086127382e ); xDrawPage.add(xShape); Anyone know what to do? Thanks! - Albert - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
[api-dev] Where should I fix Wiki errors?
Clayton, I am using a BCC to copy you directly, because I think that I really need to ask you about this. I am sending directly to the api list as a backup. I do not want to complain too loudly, since I really like these Wiki pages, but... I have seen errors in the documentation regarding the Case statement over the years. I think that some have been fixed (like in the help), but I found one on the Wiki today. I was making minor changes to the Wiki, but I really do not want to change this unless the Wiki is the master. http://wiki.services.openoffice.org/wiki/Documentation/BASIC_Guide/Branching This incorrectly states : Select Case Var Case Var 8 And Var 11 ' ... Var is greater than 8 and less than 11 . This is not correct. In fact, it is not even close. What it really does, is to evaluate (Var 8 AND Var 11), which returns a value of 0 (False) or -1 (True), and then compares Var to 0 or -1. you can do something tricky like the following, but that is pretty slick, which makes me think that Bernard Marcelly came up with it, but I do not remember now: Case Var XOR NOT(Var8 AND Var 11) Better to use To if you can use equality rather than inequality. Case 8 To 11 In my book, I have a creative IIF statement to deal with this as well. -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
[api-dev] Setting Cell Annotation text attributes
I would also like to be able to set the font for text in a CellAnnotation (note). Using the GUI, I can select text in an annotation and set the font. When I look at the Wiki, it specifically says that I can not do this: http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Spreadsheets/Cell_Annotations When I get an annotation from a cell, I see no mechanism for setting text attributes such as font. I know that I have the correct object, because I am able to obtain the text object and get the text string. Even creating a text cursor does not show that I can set properties such as font for specific portions (which is how I expected to do this). -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org
Re: [api-dev] Calc with two tables
If I understand correctly, you have solved the problem. Excellent! Rudolf Huber wrote: Hallo Andrew, thanks again for your kind response. I have to code for each sheet an extra definition between oTabellenListe = oTabellenDokument.getSheets() and Tabelle11 = oTabellenListe.GetByIndex(0) and thereafter Tabelle31 = oTabellenListe.GetByIndex(1). The additional code looks this: If TabellenListe.hasByName(Tabellen1) Then oTabellenListe.copyByName(Tabelle1, Tabelle11, 1) Rem for the Copy EndIf If TabellenListe.hasByName(Tabellen31) Then Tabelle1 = oTabellenListe.getByName(Tabelle31) MsgBox Tabelle31 found else Tabelle1 = oTabellenDokument.createInstance(com.sun.star.sheet.Spreadsheet) oTabellenListe.insertByName(Tabelle31, Tabelle1) Rem for the new sheet EndIf Yesterday, I found the solution after searching the internet again and again. You have to see, I have a problem: I am close to 70 years of age. Therefore, it takes a while until I get the point. I really appreciate help in this matter. Have I nice week. Thank you again. Rudi - Original Message - From: Andrew Douglas Pitonyak and...@pitonyak.org To: dev@api.openoffice.org Sent: Saturday, December 13, 2008 2:48 AM Subject: Re: [api-dev] Calc with two tables Rudolf Huber wrote: Halle Andrew, again thank you for your answer. I got twice the answer 1 for the printing calls. I interpret this that I have two sheets, namely sheet 0 and sheet 1. A count of 1 means that you have one sheet, and the index of the first sheet is zero. The point is, if the count is 1, then you can not obtain the sheet at index 1. As long as I had oo0 2.0, I had no problem. I handled 10 tables in one macro. On the bottom of the sheet, where I had the sheets-numbers, I always got the correct sheet numbers. Now, I use ooO 3.0, and I suddenly have problems. I assume that something else is happening. I noticed some changes with respect to how a sheet was loaded, and when a call might return, and what the reference to the loaded document might be. My mind is vague on this, however, and I never gave it much thought, at least not for a while anyway How long after the document is loaded, do you try to access the sheets? what happens if you add a delay? In our example I declare the sheets-numbers Tabelle11 and Tabelle31. As soon as I call the spreedsheet I get the sheet-number Tabelle1, which apparently is being generated by ooO. I see all the cells which I had typed when I created the table. After I call the macro, the routine goes to the point where I want to call Tabelle31. At that position I get the outofboundexception. The spreadsheet does not show either Tabelle11 or Tabelle31. The system acts as if I would have not called either Tabelle11 or Tabelle31. Here is the entire code. Hmm, now that is interesting. I can not make this code fail. Can you email me a copy of the referenced document? Option Explicit Sub Main Dim Desktop As Object Dim Platzhalter() Dim Url As String Dim oTabellenDokument As Object Dim oTabellenListe As Object Dim Tabelle11 As Object Dim Tabelle31 As Object Dim EndSpalte As Integer Dim EndZeile As Integer Dim I As Integer Dim Cursor As Object Dim ZellenBereich As New com.sun.star.table.CellRangeAddress Dim ZellenAdresse As New com.sun.star.table.CellAddress ZellenBereich.Sheet = 0 ZellenBereich.StartColumn = 0 ZellenBereich.EndColumn = 30 ZellenBereich.StartRow = 0 ZellenBereich.EndRow = 300 ZellenAdresse.Sheet = 0 ZellenAdresse.Column = 0 ZellenAdresse.Row = 0 EndSpalte = ZellenBereich.EndColumn EndZeile = ZellenBereich.EndRow In this next line, you assign to the current document, I would not do that without checking the document type and such. oTabellenDokument = ThisComponent rem oTabellenDokument.LockControllers Desktop = CreateUnoService(com.sun.star.frame.Desktop) Url = file:///a:/mist.ods oTabellenDokument = Desktop.loadComponentFromURL(Url, _blank, 0, Platzhalter()) What happens if you place a print statement here. Print hello, for example. The only purpose is to give the document time to load. I assume that the loaded document does NOT call a macro when it starts (or anything similar). oTabellenListe = oTabellenDokument.getSheets() Tabelle11 = oTabellenListe.GetByIndex(0) Tabelle31 = oTabellenListe.GetByIndex(1) End Sub You question, I I reference the correct document. I run the macro with break-points. The only point where I am nor sure of are the LockControllers and CurrentController statements. I declared them both, for the cell-area (Zellenbereich) and the entire document. I also tried getByName instead of getByIndex. I got the same outofboundexception.. I really appreciate your help. Regards, Rudi
Re: [api-dev] Removing focus from a control
Thanks Bernard... It had not occurred to me to manually set the focus on the container window. Matthias, this should solve your problem... Bernard Marcelly wrote: Hi Andrew, I found the same problem with a simple control Button. You have to set focus again on the document window (sort of). Just add this instruction at end of your macro: oFrame.ContainerWindow.setFocus By the way, I did not know the .uno:SetInputMode trick ! __ Bernard Message de Andrew Douglas Pitonyak date 2008-10-28 04:36 : I was recently asked how to solve a simple problem. A checkbox in a Calc document calls a macro when it is clicked. I want the macro to select a cell such that the cell is in input mode. Ignoring the checkbox, I can use code similar to the following: Sub CellSelectOne Dim oCell Dim oSheet REM Get the first sheet. oSheet = ThisComponent.getSheets().getByIndex(0) REM Get cell A2 oCell = oSheet.GetCellbyPosition( 0, 1 ) REM Move the selection to cell A2 ThisComponent.CurrentController.Select(oCell) Dim oFrame Dim oDisp oFrame = ThisComponent.CurrentController.Frame oDisp = createUnoService(com.sun.star.frame.DispatchHelper) oDisp.executeDispatch(oFrame, .uno:SetInputMode, , 0, Array()) End Sub I even tried this: Dim args2(0) as new com.sun.star.beans.PropertyValue args2(0).Name = ToPoint args2(0).Value = $G$4 oDisp.executeDispatch(oFrame, .uno:GoToCell, , 0, args2()) When the macro returns, the checkbox still has focus. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[api-dev] Removing focus from a control
I was recently asked how to solve a simple problem. A checkbox in a Calc document calls a macro when it is clicked. I want the macro to select a cell such that the cell is in input mode. Ignoring the checkbox, I can use code similar to the following: Sub CellSelectOne Dim oCell Dim oSheet REM Get the first sheet. oSheet = ThisComponent.getSheets().getByIndex(0) REM Get cell A2 oCell = oSheet.GetCellbyPosition( 0, 1 ) REM Move the selection to cell A2 ThisComponent.CurrentController.Select(oCell) Dim oFrame Dim oDisp oFrame = ThisComponent.CurrentController.Frame oDisp = createUnoService(com.sun.star.frame.DispatchHelper) oDisp.executeDispatch(oFrame, .uno:SetInputMode, , 0, Array()) End Sub I even tried this: Dim args2(0) as new com.sun.star.beans.PropertyValue args2(0).Name = ToPoint args2(0).Value = $G$4 oDisp.executeDispatch(oFrame, .uno:GoToCell, , 0, args2()) When the macro returns, the checkbox still has focus. -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Staroffice basic library question
Frank Schönheit - Sun Microsystems Germany wrote: Hi Craig, I have several spreadsheet documents that need to access a common set of staroffice basic macro routines that cannot be in a user application specific location (i.e. they cannot be in a user specific 'My Macros' library) I would like to be able to have the above mentioned spreadsheet documents simply load a 'module' file (e.g. common_macros.bas) of staroffice basic macros and then be able to call routines from the loaded set of macros from within macros in the spreadsheet documents. Is this possible using staroffice basic? Never tried it myself (not exactly *this* scenario, that is), but I think it should be possible. The Basic libraries are themselves accessible in UNO: There should be a BasicLibraries property at both ThisComponent (for the document) and GlobalScope (for application-wider Basic). You could create a new module within the Basic libs, and load your common_macros.bas into it from a central location. Something like oCommonLib = GlobalScope.BasicLibraries.creatLibrary( unique_name ) sModuleContent = ... ' load common_macros.bas from somewhere oCommonLib.insertByName( module_name, sModuleContent ) Of course, you need to add some sugar: How to handle the case the library/module is already there? How to handle updates (i.e. you need versioning for the common_macros.bas file), and the like. Ciao Frank In AndrewBase.odt, I demonstrate how to create modules. I do not demonstrate how to call created modules based on the routine names if given as a string, at least not in that document. -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] FilePicker File Name Questions
I was toying with adding an extension on to the exported macro save file but hadn't looked into using filters yet, so this is a help! You should take a look at AndrewBase.odt. I have a very similar example there, where you pass in a boolean to tell it to use save or open. Also, it initializes the file filters differently. Consider these two functions: Function OOoBaseFilters() OOoBaseFilters() = Array(All Files, *.*, _ OOo Base, *.odb) End Function Function GraphicFilters() GraphicFilters() = Array(All Files, *.*, _ Graphic Interchange Format, *.gif, _ Joint Photographic Experts Group, *.jpg, _ Tag Image File Format, *.tif, _ Windows Bit Map, *.bmp, _ Gimp Files, *.xcf, _ Portable Network Graphics, *.png) End Function Notice that this include a description and a file spec. Now, notice how I set the filters For i = LBound(sFilters()) To UBound(sFilters()) Step 2 Dim sFilterName$ Dim sFilterValue$ sFilterValue = sFilters(i+1) sFilterName = sFilterValue - sFilters(i) oDialog.appendFilter(sFilterName, sFilterValue) Next This uses both the description and the filter (wildcard). 2) I want to use a FilePicker to specify a file to save to, but it's not possible to specify a file that does not yet exist with the FilePicker, and I've gone through all the interfaces a FilePicker has and look at all the dialogs that seem fitting for this. I want to be able to either pick an existing file or specify a new one, the same way it's possible when saving a document for the first time or when picking Save As. For now I have to use a FolderPicker, get a folder, then ask for the file name with an InputBox. Is there some way to get a full path from a FilePicker to a file that will be created but does not exist yet Set it as a Save dialog. As an open dialog, you should not be able to open a non-existing file set this immediately after creation... oFileDialog.Initialize(Array(com.sun.star.ui.dialogs.TemplateDescript ion.FILESAVE_SIMPLE)) Other options for the templates are here: http://api.openoffice.org/docs/common/ref/com/sun/star/ui/dialogs/Tem plateDescription.html Okay -- that makes sense. I had gone through looking at dialogs and searching the API index under different letters that might have a different FilePicker or FileSavePicker or SaveFilePicker or anything like that and just couldn't find a darned thing! It works just fine! Thanks, Andrew. Hal Your welcome. -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Keypresses and Macros and Dialogs
Cor Nouws wrote: Hi Hal, Hal Vaughan wrote (17-7-2008 21:15) I've got a couple more questions and both are regarding keypresses. 1) Is there any way that a macro can wait on a keypress without using a prompt or anything like that? For example, the macro may active when F4 is pressed, then wait for the next keypress, find out what key was pressed, and act on that? I've tried looking through API docs, but I'm not sure what I'd use to listen to the keyboard. Not so much experience with this. But have you looked at this one: http://wiki.services.openoffice.org/wiki/Documentation/BASIC_Guide/Events Yuck, this is not a fun area in my opinion. If you can make it happen sufficiently fast, you can Map your special key such as F4 to call your macro. Have key F4 macro install a keyboard handler. Your keyboard handler would intercept your ONE key. While handling that one key, first remove the handler, then do the extra work that you desire to do. I think that AndrewMacro has a simple XKeyHandler example, but I would need to check. 2) When I create dialog boxes for Basic, I'm running into a problem with calling macros on events from controls. If I have a push button, I can bind an action to mouse button released and it works fine, but if I also bind it to key released, then it'll call that macro even if I'm just tabbing through the controls -- once tab is released, if that button has focus, the key release macro is called. So far I've gotten around this by creating boolean variables for each button and using two routines, one for key press and one for key up. I set the variable to true on key press and on key up/released I check and if the variable isn't true, I don't execute the bound macro. Via the UI I bind events to When initiating. And that works fine for button type Default. So try that one. Yes, this is correct. -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Selecting, Reading, and Entering Text
I do not have time to test this, so... Hal Vaughan wrote: I recorded a macro to select text, copy it to the keyboard, then to enter a new character. In the long run, I'm going to want a macro that selects the character before the cursor, then reads in that character so I can use it to compare to something else. When I'm done, I'd delete that character from the text, then enter in new text. It'd work like autotext, but it'd also let me call another macro along the way, since there's a bug (as mentioned in another thread) in autotext that doesn't let you bind macros to it. I'm using the code below to select the one character and copy it to the keyboard, then enter in another keypress. I've got a couple questions: 1) This all uses dispatch statements. I remember there were some issues with this previously, but that may have been with slot numbers or something like that. Am I safe writing my macro to dispatch commands, or will that get outdated? This will always be used from the keyboard, so there's no issue with the UI not being in use when I do this. 2) Once I've selected a character (or more text) or copied it to the clipboard, how can I read what that character is? I've looked at Andrew's Macro document, but I'm still putting all that info together and it uses objects, not the dispatcher. Is there a quick way, in Basic, to dump the selected text into a string? Thanks for any help on this! You do not say what you want to do if more than one thing is selected, but does this code make any sense to you? Function GetFirstSelectedString(oDoc As Object) As String Dim oSels Dim oSel Dim oCursor Dim i As Integer GetFirstSelectedString = If IsNull(oDoc) Then Exit Function oSels = oDoc.getCurrentSelection() If IsNull(oSels) Then Exit Function If oSels.getCount() = 0 Then Exit Function For i = 0 To oSels.getCount() - 1 oSel = oSels.getByIndex(i) oCursor = oSel.getText().CreateTextCursorByRange(oSel) If Not oCursor.IsCollapsed() Then GetFirstSelectedString = oCursor.getString() Exit Function End If Next End Function A bit less safe, but shorter. Function GetFirstSelectedString() As String Dim s$ Dim oSel Dim oSels Dim i As Integer GetFirstSelectedString = s = oSels = ThisComponent.getCurrentSelection() For i = 0 To oSels.getCount() - 1 oSel = oSels.getByIndex(i) s = oSel.getString() If Len(s) 0 Then GetFirstSelectedString = s Exit Function End If Next End Function -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Pause the script for user's input in .odt
What type of data file do you want to open? What kind of data do you want to read? How do you know where to put the data? sergio wrote: I have a script in StarBasic that find some data, then open a file and should wait for the user's input (move the cursor to the desired destination of the data), then write the data. I don't have idea on how to do this. I append the macro. Thanks in advance. Sergio REM * BASIC * Dim vData as Variant Dim Ccount as Integer Sub Main oCalc = ThisComponent StarDesktop.loadComponentFromUrl(UrlFile,_blank,0,array()) DataFinder(oCalc,1) for l = 0 to Ccount MsgBox (Place the cursor where will be the vData(l) ) next End Sub Function UrlFile oFilePicker = createUnoService (com.sun.star.ui.dialogs.FilePicker) oFilePicker.execute Url = oFilePicker.getSelectedFiles UrlFile = Url(0) End Function Function DataFinder(oCalc, Optional Row) oSel = oCalc.CurrentSelection if Row then Rcount = Row-1 else Rcount = oSel.rows.count-1 endif Ccount = oSel.columns.count-1 aData = oSel.getDataArray for i = 0 to Rcount vData = aData(i) next End Function - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Pause the script for user's input in .odt
sergio wrote: sergio ha scritto: Thanks for your answer. Your welcome, but it looks like you solved this on your own. Bravo! -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Macro Questions
Hal Vaughan wrote: On Wednesday 02 July 2008, Andrew Douglas Pitonyak wrote: I wondered if it was the same Hal :-) Yes. Originally my plans were to do an application completely in OOBasic, but that never worked out because I needed some functions that weren't available, such as reliable (and preferably encrypted) file transfer. I ended up having to learn Java and writing my app in Java. It works fine and in the first 18 months that version 1.0 was running I had something like 4-5 bug reports, including cases like a client who had troubles because my program would write out files that were later unreadable by OOo, but it turned out it was because he had bad sectors on his drive. (The files I created were okay -- just corrupted by a bad drive!) I remember at the time I was working on a way to create macros that would go with the document and hoped to write that up, but it looks like there's a better setup now. With this small project, I won't be doing anything complex. It's to help me with writing screenplays. I need 4 main macros that will change the margins to specific settings, one to ask me the script title and from there create a new directory in my writing directory for it and to put that title in the headers and title page. This next part may be off because it's been so long since I've been able to sit down and write in an actual word processor, so I don't remember if OOo uses the ALT key for any commands, but let's assume it doesn't for now. I'll have one other main macro. When I call it, it'll ask me for a phrase, which will usually be a character's name, then it'll ask me to press a key (or enter a key in a dialog box). Then it'll create a macro (hopefully for that document only) that will, within that macro, call up one of the margin setting macros, then type the name (or phrase) I entered in the dialog box. It'll also link that macro to the key I specified when used with the ALT key. I had a system like that on Word Perfect that worked just fine for me. I'm lucky, I write my screenplays for me and for the film company I'll be starting soon. I don't have to worry about many of the rules of screenplay formatting that get in the way and I prefer not to use programs designed for screenwriters -- I like doing all my writing in one program. All I need to customize it is to be able to set up the macros I just mentioned. I just wanted to get an idea of whether anyone know if it was possible to do the things I wasn't sure of before researching it. If I got a No, then I knew it wouldn't be worth the hours or days it could take to go through the API and experiment. I can post the results when I'm done, if it'll help. Hal Remember, never do more work than you need to make You may be able to use auto formatting to do the same thing. I have not used it I thought that you could set formatting and everything. The idea would be something like this: You enter some specific text. Press a key like Ctrl+F3 Based on the text that is present, new text and/or formatting is applied I need to search around OOo a bit to figure it out, but it might be one of these. (and I need to be somewhere soon so I can not look now). http://wiki.services.openoffice.org/wiki/Documentation/OOoAuthors_User_Manual/Writer_Guide/Using_AutoText http://wiki.services.openoffice.org/wiki/Documentation/OOoAuthors_User_Manual/Writer_Guide/Autoformatting The bottom line is that you would simply need to create the entry and then use it. This might be easier than the macro, perhaps not... -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Macro Questions
Hal Vaughan wrote: On Saturday 05 July 2008, Andrew Douglas Pitonyak wrote: Hal Vaughan wrote: ... You enter some specific text. Press a key like Ctrl+F3 Based on the text that is present, new text and/or formatting is applied I need to search around OOo a bit to figure it out, but it might be one of these. (and I need to be somewhere soon so I can not look now). http://wiki.services.openoffice.org/wiki/Documentation/OOoAuthors_Use r_Manual/Writer_Guide/Using_AutoText http://wiki.services.openoffice.org/wiki/Documentation/OOoAuthors_Use r_Manual/Writer_Guide/Autoformatting The bottom line is that you would simply need to create the entry and then use it. This might be easier than the macro, perhaps not... I have to look into it, but the advantage of a macro is that once I specify the macro, it happens in one keystroke every time. It sounds like this means I'd type the full text, THEN specify the formatting. The idea is that even though all I'm typing is names, I can still set the margins and type the name in one stroke. This other way I'd have to type the name, then hit the keys for formatting. I have wondered about using an F key instead of a key combination. For example, there are some F keys that aren't used. I thought at one point I had found a way to make OOo listen after a keypress. In other words, I could type something like, say, F6 and it might trigger a macro that does nothing but listen for the next key until it gets a keypress. Then when it does, it dispatches the control to the appropriate macro. No, if it works, it would look more like this: You enter the text park and press Ctrl+F3, or something similar, and then it replaces Park with something, and formats it. Certainly, this can be done in a macro, but if the auto-formatting stuff can also do this, then, well, it would be easier :-) In a script you often have a lot of dialog, which means typing people's names at that place in the center of the page or with that widest margin 20 times or so in a page. I considered this with respect to scripts for puppets. I considered storing names in fields so that I could instantly change a name everywhere at one time. When I first started checking out OOo, I was concerned because OOo doesn't do actual margin changes without forcing a page break (a serious flaw, as I see it), so when I did early imports from Word Perfect, I'd get one line per page in many cases and it's only after the filter was created to import Word Perfect documents that the situation changed. I still think that you should use paragraph styles. -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Macro Questions
I wondered if it was the same Hal :-) Hal Vaughan wrote: I've been otherwise occupied so I haven't had time to read the answers closely on this (I had time, sent my second post and literally within hours had to jump and start putting out some fires with some of my software), but I'm not surprised the first answer I get is from Andrew. I think it was around 4, maybe even 5 years when I was much more active on this list and if there was an answer needed and nobody had it, Andrew had an idea or suggestion or answer. Thanks, both of you, for the info. I'll be looking through this and experimenting over the next week and I'll let you know what I am able to do and how it works. Both answers are much appreciated! Hal On Tuesday 24 June 2008, Hal Vaughan wrote: I used to have some rather advanced stuff set up in OOoBASIC, but that was back before 2004. I have use the API from Java to do some work as well. It's been a good while since I've delved into working with macros and OOoBASIC. I've got a few questions. I'm not trying to get anyone to tell me how to do these things, but I just want to get an idea of whether what I want to do is possible through the API. I operate in two modes. When I'm in geek mode, I'm focused on programming and can handle the technical stuff and don't mind taking all the time it takes to figure something out, but when I'm in nerd mode, I'm writing and I want to be thinking about writing, not about how the word processor works or anything like that. I can take my time and set things up while I'm doing the tech stuff, but once I'm focused on writing, I need to think about dialog, plot, characters, and things like that. I write mainly screenplays, which have margin changes (which would be paragraph indents in OOo). I've spent the past 7 years programming, with little or no free time and now I finally have time to write a script. Previously I used Word Perfect. I know I'll have to use different key definitions, but essentially, under Word Perfect, I had 4 main macros, bound to the keys CTRL-1 to CTRL-4. All I had to do was press one of those keys to set the margin. I know I can do the same under OOo with margin changes. Now here's the more difficult part: When I'm writing dialog, the character's name is in all caps, in the center of the page. I used to set it up so ALT-A would center and print Anne, ALT-B would center and print Bob and so on for all the characters I used a lot in my script. This is where I'm running into problems. In Word Perfect all I had to do was hit the keys to define a macro, hit the key I'm defining, then press CTRL-4 and type the name of a character, then when done, hit the stop recording key. Then the next time I hit the key, it calls the CTRL-4 macro for the margin (actually to center the name), then prints the name. I know to bind a macro to a key I have to go through the menu, by hand, which is 3-4 steps to get there. I also can't easily include one macro in another macro. So here's what I'm thinking I'd like to do: Write a macro that would prompt for specific text, then ask for the key I want to bind it to. Once I enter both, it not only creates the macro on it's own (automatically naming it), but also binds it to the key mentioned (preferably only in that document). That way I can quickly define macros on the go, while I'm writing, and just as quickly, in the same process, define the key it is bound to. I know quite a bit is available through the API, but can I manage macros through the API like this so one macro can define other macros and bind them to keys? Basically, I don't mind taking time to write the code ahead of time, but it's critical to be able to set this up so my writing process is not disturbed by having to click through menus or do anything else involved when I set up macros. I don't mind combing through API docs, but I want to be sure this can be done before spending a long time searching for something that may not be there. Thanks for any help on this! Hal - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[api-dev] What is the BASIC command Me?
How can I call the Me command in Basic? The command is defined as follows: // #115824 RTLFUNC(Me) { (void)pBasic; (void)bWrite; SbModule* pActiveModule = pINST-GetActiveModule(); SbClassModuleObject* pClassModuleObject = PTR_CAST(SbClassModuleObject,pActiveModule); if( pClassModuleObject == NULL ) { StarBASIC::Error( SbERR_INVALID_USAGE_OBJECT ); } else { SbxVariableRef refVar = rPar.Get(0); refVar-PutObject( pClassModuleObject ); } } Am I better off not documenting this method? Note that I am looking at OOo 3.0 development builds -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[api-dev] Find defined routines, functions, and constants
I would like to document the current methods, functions, constants, and similar in OOo for version 3.0, but I am not certain where everything is defined. For example: - I looked in basic/source/runtime It looks like RTL is defined in stdobj.cxx and implemented in methods.cxx, but I can not call it from Basic because the method is listed as not defined. I see many defined constants in stdobj.cxx such as IDABORT, so this feels like a good place to look. I also see many items in basic/source/comp/token.cxx How about recognized VBA keywords? oovbaapi/genconstidl/*.api? -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Accepting and rejecting redlines
No answers here, to this question asked a few times over the years, and also on the forums: How to use a macro to accept or reject individual changes (redlines). I opted to document as much as I could. I demonstrate here how to enumerate redlines, and a cheat method to delete them, but not how to accept them, and this is certainly not the correct method! While recording changes, they are saved as “redlines”. Although you can easily enumerate the redlines, I have not found a way to do anything useful with them. Specifically, I am not able to obtain the text, or move a cursor to the redline, even though I can obtain the “start” and “end” of the redline. Listing 7.67: Enumerate redlines. oEnum = ThisComponent.redlines.createEnumeration() Do While oEnum.hasMoreElements() oRedLine = oEnum.nextElement() 'oRedLine.RedlineType 'oredline.redlineauthor 'oredline.redlinecomment loop I am, however, able to do some work by enumerating the text content (see Listing 7.53). The following simple macro ignores things such as tables and frames, but it provides some insight into how to deal with redlines. Sub EnumerateRedlineContent REM Author: Andrew Pitonyak Dim oParEnum 'Enumerator used to enumerate the paragraphs Dim oPar 'The enumerated paragraph Dim oSectionEnum 'Enumerator used to enumerate the text sections Dim oSection 'The enumerated text section Dim oCurs 'Track the redlines. Dim oText oParEnum = ThisComponent.getText().createEnumeration() Do While oParEnum.hasMoreElements() oPar = oParEnum.nextElement() If oPar.supportsService(com.sun.star.text.Paragraph) Then oSectionEnum = oPar.createEnumeration() Do While oSectionEnum.hasMoreElements() oSection = oSectionEnum.nextElement() If oSection.TextPortionType = Redline Then If oSection.IsStart Then 'At a start, so create the text cursor. oText = oSection.getText() oCurs = oText.createTextCursorByRange(oSection.getStart()) Else 'Move cursor to the end of the redline. oCurs.gotoRange(oSection.getEnd(), True) Print oSection.RedlineType oCurs.getString() End If End If Loop End If Loop End Sub A quick test, that did not check things such as formatting changes, seemed to indicate that I can delete a section by setting the string to an empty string. If oSection.RedlineType = Delete Then 'Delete the range! oCurs.setString() End If I have not, however, found any other method to remove a redline using a macro. I have also not found a method to accept an individual redline. -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Bugs in 3.0 Beta holding up documentation
Thanks, I will download the latest. I was using m18 I was having trouble finding the link. Ariel Constenla-Haile wrote: Hi Andrew, Andrew Douglas Pitonyak escribió: I am attempting to update documentation for 3.0, and I was dealing with macros in Calc documents. I noticed that I can not call a macro as a Calc function. with DEV300_m19 on Linux an OOo Basic function can be used as a function in Calc I think that the problem is related to an existing bug report... http://www.openoffice.org/issues/show_bug.cgi?id=89527 don't know on Windows (as reported on this issue), but on Linux event binding also works in DEV300_m19 Will there be another beta that may allow me to keep working? If a new beta is not expected for a while, where can I find the latest development builds? the latest is DEV300_m19 and can be found in http://ftp5.gwdg.de/pub/openoffice/extended/developer/ the folder with the highest number is the latest dev. snap. (today DEV300_m19) Regards Ariel. -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[api-dev] Bugs in 3.0 Beta holding up documentation
I am attempting to update documentation for 3.0, and I was dealing with macros in Calc documents. I noticed that I can not call a macro as a Calc function. I think that the problem is related to an existing bug report... http://www.openoffice.org/issues/show_bug.cgi?id=89527 Will there be another beta that may allow me to keep working? If a new beta is not expected for a while, where can I find the latest development builds? -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[api-dev] Accepting and rejecting redlines
Aroslav Resovsky, I am posting this to the dev mailing list since I have never seen an answer to this question, but I have seen it asked a couple of times on the dev mailing list. What is the accepted method for accepting or rejecting a change? I know that I can accept all of the changes using a dispatch: Sub AcceptTrackedChanges dim document as object dim dispatcher as object document = ThisComponent.CurrentController.Frame dispatcher = createUnoService(com.sun.star.frame.DispatchHelper) dispatcher.executeDispatch(document, .uno:AcceptTrackedChanges, , 0, Array()) End Sub I can enumerate the text and find the start and end redline changes. What is the expected method to accept or reject a single change? My guess: To Delete: Select the text from the change start to the change end, and then simple set it to an empty string. To accept: Select the readline text content for begin and end and then delete it. I have not tried this yet, but I will if that is the expected method. -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Set Ranges in an XY Chart
Thanks, I will try this Daniel Rentz wrote: Andrew Douglas Pitonyak schrieb: How can I create an XY chart from a macro where each Y data value has its own X data value. I know how to do this by hand because I can individually specify these using the GUI. I can not, do this using a macro. Not sure if this is possible with the chart1 API, but it can be done using the chart2 API. Following some hand-written untested (!) BASIC code, that creates a new XY chart. 1) create or get a chart document oChart = ... 2) let the Calc document create a data provider, set it at the chart oDataProv = ThisComponent.createInstance( com.sun.star.chart2.data.DataProvider ) oChart.attachDataProvider( oDataProv ) 3) insert a diagram into the chart document oDiagram = CreateUnoService( com.sun.star.chart2.Diagram ) oChart.setFirstDiagram( oDiagram ) 4) insert a coordinate system into the diagram oCoordSys = CreateUnoService( com.sun.star.chart2.CartesianCoordinateSystem2d ) oDiagram.addCoordinateSystem( oCoordSys ) 5) insert an XY chart type into the coordinate system oChartType = CreateUnoService( com.sun.star.chart2.ScatterChartType ) oCoordSys.addChartType( oChartType ) 7) insert a data series into the chart type oSeries = CreateUnoService( com.sun.star.chart2.DataSeries ) oChartType.addDataSeries( oSeries ) 8) let the data provider of Calc create data sequences from formulas: oSequenceX = oDataProv.createDataSequenceByRangeRepresentation( $Sheet1.$A$2:$A$6 ) oSequenceX.Role = values-x oSequenceY = oDataProv.createDataSequenceByRangeRepresentation( $Sheet1.$B$2:$B$6 ) oSequenceY.Role = values-y oSeriesTitle = oDataProv.createDataSequenceByRangeRepresentation( $Sheet1.$B$1 ) oSeriesTitle.Role = label 9) create labeled data sequences which combine the series title and series values: oLabeledX = CreateUnoService( com.sun.star.chart2.data.LabeledDataSequence ) oLabeledX.setValues( oSequenceX ) ' no title for X values oLabeledY = CreateUnoService( com.sun.star.chart2.data.LabeledDataSequence ) oLabeledY.setValues( oSequenceY ) oLabeledY.setLabel( oSeriesTitle ) 10) create an array from the labeled sequences (not sure about the correct BASIC syntax...), set it at the data series Dim aSeqArray( 0 to 1 ) As Object aSeqArray( 0 ) = oLabeledX aSeqArray( 1 ) = oLabeledY oSeries.setData( aSeqArray() ) Hope this helps. Not sure if everything above is correct, so please feel free to complain or ask ;-) Daniel - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Changes to the navigation box on the Dev Guide (and other books)
ccornell - OpenOffice.org wrote: A community member (Nashev) has made some changes to the MasterTOC template used to create the book navigation box on the right side of the Developer's Guide (and other books that use this same template). Changes made are: - Next Page and Previous Page links have been moved from above the article text to the bottom of the navigation box. - Next Part and Previous Part have been moved from the bottom of the navigation box to near the top of the box. - The Part (chapter) label has been left justified and the font style/size changed. For examples of the old and new styles, see here: http://wiki.services.openoffice.org/wiki/Template_talk:Documentation/MasterTOC Do you guys feel that these changes are an improvement? I have little opinion about the centered text at the top of the page. I do, however, prefer having the navigation buttons at the top as well as at the bottom. +1 for the new style. -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Wait Cursor
last I checked, this is what I found (in OOo version 1.3) Mathias Bauer, whom we all love, responded. You can not set the mouse pointer of a document window via UNO-API. VCL manages the mouse pointer based on the window, not the top window. Any VCL window can have its own mouse pointer set. If you want to change the mouse pointer of the document window, you must access its XWindowPeer (not the peer of the frame window), and this is not available in the API. Another problem might be that OOo changes the mouse pointer internally and overrides your setting. Berend Cornelius provided the final response. Your Sub works fine with any sub-window in your document. The following code refers to a control in a document: /*Listing 5.56: *Switch the mouse pointer for a control./ Sub Main Dim oController Dim oControl Dim oDrawControl GlobalScope.BasicLibraries.LoadLibrary(Tools) oController = Thiscomponent.getCurrentController() oDrawControl = ThisComponent.Drawpage().getbyIndex(0).getControl() oControl = oController.getControl(oDrawControl) SwitchMousePointer(oControl.getPeer(), False) End Sub This routine changes the mouse pointer when it is over the control, but when the pointer is not over the control window it changes back. You want a Wait function that places the pointer in a wait state but this is currently not supported by the API. It is my opinion that you can change it but not for all things. oDoc.getCurrentController().getFrame().getContainerWindow().setPointer(...) -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Java in Windows and OOo uses different Paper Tray names
Tobias Krais wrote: Hi Andrew, I thought that the tray names were set in the PPD file (for post script printers anyway). For example, read page 101 of this document http://partners.adobe.com/public/developer/en/ps/5003.PPD_Spec_v4.3.pdf This means OOo seems to read it from the ppd. Won't be platform independent in case I want to do it this way... Thank you. Greetings, Tobia I do not know that OOo does this, but I was guessing that the O/S may do this. If the O/S does this and then OOo asks the O/S, then it will find different names potentially. It would be nice if OOo provide a Service to return this type of information. -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Java in Windows and OOo uses different Paper Tray names
Tobias Krais wrote: Hi together, at the moment I encounter a serious problem on Windows OS. I wrote a little OOo dialogue allowing the user to print a document on a certain tray of a printer. Now my Problem: for OOo does not offer an API to get printer tray names, I use the API of Java. It returns me, for example the Tray name Multi Purpose Feeder for a certain tray. OOo knows this very tray, but it is named Multifunktionseinzug in the OOo print dialogue. Thus OOo uses the German name and Java the English one. This makes it impossible for me, to set a printer tray using OOo API. Here my question: 1. Is anybody here on this list, encountering the same problem? 2. How does OOo retrieve the printer tray names? Maybe I can do it the same way to get the tray names as OOo uses it. 3. Do you have any other hints how I can solve the problem? I hope you have any suggestions on this issue! Greetings, Tobias I thought that the tray names were set in the PPD file (for post script printers anyway). For example, read page 101 of this document http://partners.adobe.com/public/developer/en/ps/5003.PPD_Spec_v4.3.pdf Probably find more documents here: http://partners.adobe.com/public/developer/ps/index_specs.html -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] merge table columns example
I believe that a text table has different support than a Calc document I only show how to merge and split text table cells in my book (and not in my free macro document). Have you looked at the developer's guide? Nicole Scholz wrote: Hi! I found some examples of merging columns in scalc and I tried to transfer the code into writer. Unfortunately I was not able to get it running. I created a CellRange of the Table in Writer and then tried to merge the cellRange. CellRange = xTextTable~xCellRange~getCellRangeByName(Arow:Brow) CellRange~XMergeable~merge(.true) When I run the program I get the following error message: Object The NIL object does not understand message MERGE Do I create the CellRange wrong or call the merge method wrong? Thanks Nicole Original-Nachricht Datum: Sat, 10 May 2008 22:59:24 +0200 Von: Nicole Scholz [EMAIL PROTECTED] An: dev@api.openoffice.org Betreff: [api-dev] merge table columns example Hi! I try to merge two columns in one row of a table. I read the developer guide and I searched the mailing list and so I found out that the XMergeable Interface is needed and that I have to set the method merge to true. But I dont know how to do this. How do I say which columns I want to merge? Can someone give me a short example? Thanks Nicole -- Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten Browser-Versionen downloaden: http://www.gmx.net/de/go/browser - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Performance issues regarding VB6 and OpenOffice.org
I noticed that with a large mail merge, the time was growing very very very long... Boris Ratak wrote: Hi, I'm working on a VB6 application that creates documents using OpenOffice.org (2.2.1 and 2.3.1, Windows XP and 98). I'm noticing performances issues with OpenOffice that didn't occur when the software was using MS Word. When I generate several documents (or several times the same document), the time spent on each document is longer and longer. (I use pretty basic features, like opening/closing documents, putting text in bookmarks, manipulating some texttables...) After ten documents, the time spent is still approximatively the same, but after twenty, it spends twice or more the time he used to. I've tried to clean my code, unsetting every OOo object after use, even tried to unset the automation link after every document closed, but nothing changes. I only have I soffice.exe and one soffice.bin process. So my question is : has onyone of you noticed performances issues when using OOo in a VB6 program ? Or even memory leaks ? Thx - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Macros: argument is not optional
Download AndrewMacro.odt and take a look at chapter 9 Formatting macros -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Code-Highlighting in Basic IDE
I have a new copy of the formatter now. I made some changes: 1. I format Java, C++, and StarBasic. 2. If the character styles do not exist, I create them. 3. Pass in character style names in an array of strings rather than hard coding them. 4. Added a document dedicated to the code formatter. It was suggested that perhaps this should be packaged. I have never created a package. Anyone care to do this? I added http://www.pitonyak.org/CodeFormatter.odt to http://www.pitonyak.org/oo.php -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Code-Highlighting in Basic IDE
Laurent Godard wrote: Hi @ariel: If you can provide this code to me, I can save a lot of time. After going through the code yesterday this was also my idea: creating the styles if the are not existing - or import them from a masterdocument. But if you have code to create them - fine, that should save time. very interresting feature would it be possible to adapt to other languages (java, c++, python (i have already one for thsi) What about packaging as an extension ? Laurent Sorry, I have been busy. I will add the modifications mentioned by Ariel (have not yet done it). That said, the updated AndrewMacro.odt contains the code to highlight Java as well. It is not perfect by any stretch. For example, it does not properly recognize hex constants. The trick is that I need to write the recognizer for each type. You know, is this a constant or a variable. I suppose that if it does not start with a valid identifier, I can just assume that it is a constant. Hmm, that is probably easier. This might be a nice thing to package as an extension. -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Code-Highlighting in Basic IDE
Thomas Krumbein wrote: Hi Ariel, hi Malte, thank you for the information. Ariel Constenla-Haile schrieb: [..] See Andrew Pitonyak's Macro Document at http://www.pitonyak.org/AndrewMacro.odt chap. 9 Formatting macros containg macros to format Basic code just like the IDE does. OK, this is a fine start - and helps me really. Best regards Thomas My code relies on certain paragraph styles identifying the code and then uses character styles to format the different portions. If you highlight an entire formatted Calc Macro, you will have all of the required character styles. I should check to see if I have the latest copy in my macro document I know that at one point I speed it up a lot. If you desire the latest copy as a library email me and let me know. -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] list of propertyName's
Atte André Jensen wrote: Hi My cursor is over some text. I'd like to read the propertyes of the selection as with (in php): $propertyValue = $cursor-getPropertyValue('CharWeight'); Where can I see a list of possible propertyName's similar to CharWeight? You can inspect the object with XRay, you can inspect the object in the IDE, you can look at the definition online, you can look at the debug properties of the object. -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Styling cells in a spreadsheet in Basic
I think that you set borders either using a Style (just a guess, never have done it, but it would imply that the style itself specifies the border), or by manipulating a cell (or probably a cell range, I am guess rather than grabbing a copy of my book). I know that I do cover this in my book, and maybe in my free macro document. I do have this bit of code sitting around (and I see that it uses a table, oops) Dim v Dim x v = oTable.TableBorder x = v.TopLine x.OuterLineWidth = 2 v.TopLine = x x = v.LeftLine x.OuterLineWidth = 2 v.LeftLine = x x = v.RightLine x.OuterLineWidth = 2 v.RightLine = x x = v.TopLine x.OuterLineWidth = 2 v.TopLine = x x = v.VerticalLine x.OuterLineWidth = 2 v.VerticalLine = x x = v.HorizontalLine x.OuterLineWidth = 0 v.HorizontalLine = x x = v.BottomLine x.OuterLineWidth = 2 v.BottomLine = x 'v.Distance = 51 oTable.TableBorder = v This just gives you a hint at how to do what you want, since it likely does not do what you want. Notice that I do stupid things like this... x = v.BottomLine x.OuterLineWidth = 2 v.BottomLine = x This is because the following will fail: v.BottomLine.OuterLineWidth = 2 This fails because v.BottomLine returns a copy of the structure, rather than a reference to the structure. so, what the working code does, is to create and modify a copy, then assign it back. So, why does assigning it back work rather than just assign it to a copy? Well, you ask too many question :-) or, it is because it is internally treated as a set (I did not check the real reason). Alexandro Colorado wrote: thanks oliver however I dont see how to get the borders and width since is not color based is nowhere to be found near that IDL. The only border I found was for table which I am not sure is the same as the spreadsheet borders. On Tue, 23 Oct 2007 11:14:45 -0500, Oliver Brinzing [EMAIL PROTECTED] wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi Alexandro REM * BASIC * OPTION EXPLICIT Sub Main Dim oDoc as Object Dim oCell as Object Dim oRange as Object Dim oStyles as Object oDoc = ThisComponent 'direct (hard) cell formating ... oCell = oDoc.getSheets().getByIndex(0).getCellByPosition(0,0) oCell.CellBackColor = 256 'direct range formating ... oRange = oDoc.getSheets().getByIndex(0).getCellRangeByPosition(2,2,4,4) oRange.CellBackColor = 128 ' soft format via a cell style oStyles = oDoc.StyleFamilies.getByName(CellStyles) ' change color of build in cell style Result oStyles.getByName(Result).CellBackColor = 192 ' apply to a range ... oRange = oDoc.getSheets().getByIndex(0).getCellRangeByPosition(2,6,4,8) oRange.CellStyle = Result End Sub Oliver Am 23.10.2007 17:50 schrieb Alexandro Colorado: Hi I want to know how to style cells in a spreadsheet, things like background color, border and width. I am not sure if this is the best list to ask OOoBasic questions but there it goes. If there is a better list for this, please let me know. - -- GnuPG key 0xCFD04A45: 8822 057F 4956 46D3 352C 1A06 4E2C AB40 CFD0 4A45 -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.7 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHHh31TiyrQM/QSkURArOdAJ0bgbsdZGNh3MBpJwRowAVDQSkGKQCfXg8b vyhxJyPIP2TOUSP4nX3cyvA= =dYkK -END PGP SIGNATURE- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Getting printers via Basic or Java
Download my free macro document and search for Listing the supported printers This is for Basic. Tobias Krais wrote: Hi togehter, I have to write a little uno package managing printer options. Up to OO 2.0, it was not possible to get the available printers via OO Basic. Can you tell me whether this is possible now? If not, I have to write this extension in Java... -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Print Listeners in OOo 2.0.2 (Urgent!)
Have you seen the solution in my macro document? This might only work if the GUI is present (ie, not in headless mode). Tobias Krais wrote: Hi Hal, Code would be a big help so I could compare what we've got. I'll be glad to send you what I have. Right now I'm working with a wrapper class to handle basic functions. Do I understand, though, that you run the program once for each file you print? Or does it loop through and print multiple files without being re-run? My program runs once for each file. But modifying it shouldn't be a problem for it is in good object oriented style. It's not on this topic, but I see you had a question about getting the list of printers in BASIC. I can't do that, but I do have a routine that gets the lists of printers on a system from Java. It doesn't work directly with OOo, but it can get all the printers. Will that help you? Yes, it will. That will be the solution I plan to implement if it does not work in BASIC. I'll send you a private mail with the relevant code. Greetings, Tobias - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] AWT TREE: OOoBasic version of the ScriptSelector example
Ariel Constenla-Haile wrote: PS 2: though my English is very me-Tarzan-you-Jane, No, your English is much better than that. isn't it wrong Childs as plural of Child, instead of Children? Children is the correct plural for Child. The Java API uses Children for the plural ( z.B. DefaultMutableTreeNode.allowsChildren , .children, .getAllowsChildren() ... ), OOo API Childs. -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Open Office VBA porting? or leave as it is?
I started this a few years back (so it is dated and incomplete), but it might be useful. I think that on the hosting web page, there are better links, but I threw this up just because I had it sitting around. http://www.pitonyak.org/OOoBasicVBCompare.pdf Simon B. Margulies wrote: thanks for your answers! I'm now looking into porting the existing vba-code to StarBasic and trying to get java working for future developments. thanks a lot simon On 30.07.2007, at 22:39, Andrew Douglas Pitonyak wrote: Simon B. Margulies wrote: Hi all, I'm still evaluating open office as the new solution for my parents tax software, which has been built in excel with some vba scripts. ... What do you think? Are there any developers using VBA in Open Office? Is VBA supported in openoffice for windows AND os x? Should all be ported to some other scripting language? I suspect that I do not properly understand what you are proposing. Are you proposing to continue using VBA and then use that to access OOo? This would not be very cross-platform compatible. Using Java should be, but it has a higher learning curve and you still need to learn the OOo API. Have you considered using StarBasic included with OOo? -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] how to do custom formula functions embedded in the document?
Ionel Maries Cristian wrote: I belive some form of macro would be suitable for this job. The function has to fetch some xml from a remote url, the xml has to be parsed and the parameters for the url are sent as post data (as xml) I've failed to find apis for doing url fetching in basic. Python would be suitable for doing that (rich standard library, good docs) but, again, i've failed to find a way to use python functions as formula functions (basic functions are callable from a formula but, there is no obvious way to call some python functions from the basic macro) Any help is apreciated. Have you looked at any stock quote examples with Calc? They usually obtain a document from a URL of some sort and then parse it. -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Open Office VBA porting? or leave as it is?
Simon B. Margulies wrote: Hi all, I'm still evaluating open office as the new solution for my parents tax software, which has been built in excel with some vba scripts. ... What do you think? Are there any developers using VBA in Open Office? Is VBA supported in openoffice for windows AND os x? Should all be ported to some other scripting language? I suspect that I do not properly understand what you are proposing. Are you proposing to continue using VBA and then use that to access OOo? This would not be very cross-platform compatible. Using Java should be, but it has a higher learning curve and you still need to learn the OOo API. Have you considered using StarBasic included with OOo? -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Vá: Insert a Draw docum ent into a gallery
My guess is that this is a bug, so I will probably open a bug report. I did check the code, but there are a few things that require a much deeper understanding of the code than I have. Well, it would likely take hours to understand even though it is also likely very simple. See svx/source/unogallery/unogaltheme.cxx ::sal_Int32 SAL_CALL GalleryTheme::insertDrawingByIndex( const uno::Reference lang::XComponent Drawing, sal_Int32 nIndex ) throw (lang::WrappedTargetException, uno::RuntimeException) { const ::vos::OGuard aGuard( Application::GetSolarMutex() ); sal_Int32 nRet = -1; if( mpTheme ) { GalleryDrawingModel* pModel = GalleryDrawingModel::getImplementation( Drawing ); if( pModel pModel-GetDoc() pModel-GetDoc()-ISA( FmFormModel ) ) { nIndex = ::std::max( ::std::min( nIndex, getCount() ), sal_Int32( 0 ) ); if( mpTheme-InsertModel( *static_cast FmFormModel* ( pModel-GetDoc() ), nIndex ) ) nRet = nIndex; } } return nRet; } Kálmán Szalai wrote: Andrew Douglas Pitonyak [EMAIL PROTECTED] 07/18/07 1:59 du. Worst case: I will see if I can read the SVG and then export it as a different graphic type and then add that to the gallery. If we can run a different command line to convert all SVG files to something else, however, that might be easier. --- We can convert it to ODG easily. This method is very same as SVG filter extension in OOo. So we can convert SVG-ODG -- the quality of conversion is not perfect but good enough, so it produces usable output. -- The API looks like it claims to support a Draw document. If I do not receive an answer here, I will see if I can download the latest copy of the code, check the code and then based on what I see there, I might open a bug report. the wording sounds like it might want something other than the document (because it uses the word MODEL, but it also indicates that it wants an XComponent interface). --- Interesting thing -- gallery - itself does not support sxd and odg files. So you can't add it to the gallery via UI. it is might caused because OOo does not support self format in gallery internally... I do not know, we mighe have to ask ka@ about this. We have an issue about non importable sxd, odg files into gallery but no progression here... KAMI Kálmán Szalai wrote: Hello Andrew and Developers! I checked the stability of SVG filter and some files not converted that simple command line java application does. This application produce odg files from svg, so I would like to know how we can import odg files. The UI of gallery does not support to add odg and sxd files (interesting? - the gallery supports many formats but not the default OpenOffice.org formats)... Are there any way to import odg files via API? Best regards, KAMI Andrew Douglas Pitonyak [EMAIL PROTECTED] 07/18/07 5:57 de. OOo has very little clipart. I was asked to write a macro that will create OOo clipart galleries from existing folders of clipart. I figured out how to insert links from a URL oTheme.insertURLByIndex(sURL, 0) I figured out how to insert the object as a graphic Dim oProvider 'GraphicProvider service. oProvider = createUnoService(com.sun.star.graphic.GraphicProvider) Dim oProps(0) as new com.sun.star.beans.PropertyValue oProps(0).Name = URL oProps(0).Value = sURL REM Returns a graphic object from the URL to the graphic. oTheme.(oProvider.queryGraphic(oProps()), 0) Apparently, a large collection of available clipart exists in SVG format. I installed the SVG importer from here: http://www.ipd.uni-karlsruhe.de/~hauma/svg-import/ I looked at the API, and it looks like I can insert a draw document directly: http://api.openoffice.org/docs/common/ref/com/sun/star/gallery/XGalleryTheme.html I tried it using this code: Dim oDoc Dim ImportArgs(0) As New com.sun.star.beans.PropertyValue ImportArgs(0).Name = FilterName ImportArgs(0).Value = draw_svg_import oDoc = StarDesktop.LoadComponentFromURL(sURL, _blank, 0, ImportArgs()) If NOT IsNull(oDoc) AND NOT IsEmpty(oDoc) Then oTheme.insertDrawingByIndex(oDoc, 0) oDoc.close(True) End If A -1 is returned, which means that the image was not added (I can also see that the image is not added). If you want to run the entire macro, it will be here until I resolve this problem (at which point, I will likely move it someplace on my macros page). http://www.pitonyak.org/OOoGalleryImport.odt -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html
Re: [api-dev] Insert a Draw document into a gallery
It is possible to add a Draw document to a gallery? I tried oTheme.insertDrawingByIndex(oDoc, 0), which looks like it should work based on the API, but it does not work. http://www.pitonyak.org/OOoGalleryImport.odt I traced things to this code in svx/source/unogallery/unogaltheme.cxx ::sal_Int32 SAL_CALL GalleryTheme::insertDrawingByIndex( const uno::Reference lang::XComponent Drawing, sal_Int32 nIndex ) throw (lang::WrappedTargetException, uno::RuntimeException) { const ::vos::OGuard aGuard( Application::GetSolarMutex() ); sal_Int32 nRet = -1; if( mpTheme ) { GalleryDrawingModel* pModel = GalleryDrawingModel::getImplementation( Drawing ); if( pModel pModel-GetDoc() pModel-GetDoc()-ISA( FmFormModel ) ) { nIndex = ::std::max( ::std::min( nIndex, getCount() ), sal_Int32( 0 ) ); if( mpTheme-InsertModel( *static_cast FmFormModel* ( pModel-GetDoc() ), nIndex ) ) nRet = nIndex; } } return nRet; } What kind of drawing can I insert? -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Vá: Insert a Draw docum ent into a gallery
Worst case: I will see if I can read the SVG and then export it as a different graphic type and then add that to the gallery. If we can run a different command line to convert all SVG files to something else, however, that might be easier. The API looks like it claims to support a Draw document. If I do not receive an answer here, I will see if I can download the latest copy of the code, check the code and then based on what I see there, I might open a bug report. the wording sounds like it might want something other than the document (because it uses the word MODEL, but it also indicates that it wants an XComponent interface). Kálmán Szalai wrote: Hello Andrew and Developers! I checked the stability of SVG filter and some files not converted that simple command line java application does. This application produce odg files from svg, so I would like to know how we can import odg files. The UI of gallery does not support to add odg and sxd files (interesting? - the gallery supports many formats but not the default OpenOffice.org formats)... Are there any way to import odg files via API? Best regards, KAMI Andrew Douglas Pitonyak [EMAIL PROTECTED] 07/18/07 5:57 de. OOo has very little clipart. I was asked to write a macro that will create OOo clipart galleries from existing folders of clipart. I figured out how to insert links from a URL oTheme.insertURLByIndex(sURL, 0) I figured out how to insert the object as a graphic Dim oProvider 'GraphicProvider service. oProvider = createUnoService(com.sun.star.graphic.GraphicProvider) Dim oProps(0) as new com.sun.star.beans.PropertyValue oProps(0).Name = URL oProps(0).Value = sURL REM Returns a graphic object from the URL to the graphic. oTheme.insertGraphicByIndex(oProvider.queryGraphic(oProps()), 0) Apparently, a large collection of available clipart exists in SVG format. I installed the SVG importer from here: http://www.ipd.uni-karlsruhe.de/~hauma/svg-import/ I looked at the API, and it looks like I can insert a draw document directly: http://api.openoffice.org/docs/common/ref/com/sun/star/gallery/XGalleryTheme.html I tried it using this code: Dim oDoc Dim ImportArgs(0) As New com.sun.star.beans.PropertyValue ImportArgs(0).Name = FilterName ImportArgs(0).Value = draw_svg_import oDoc = StarDesktop.LoadComponentFromURL(sURL, _blank, 0, ImportArgs()) If NOT IsNull(oDoc) AND NOT IsEmpty(oDoc) Then oTheme.insertGraphicByIndex(oDoc, 0) oDoc.close(True) End If A -1 is returned, which means that the image was not added (I can also see that the image is not added). If you want to run the entire macro, it will be here until I resolve this problem (at which point, I will likely move it someplace on my macros page). http://www.pitonyak.org/OOoGalleryImport.odt -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[api-dev] Insert a Draw document into a gallery
OOo has very little clipart. I was asked to write a macro that will create OOo clipart galleries from existing folders of clipart. I figured out how to insert links from a URL oTheme.insertURLByIndex(sURL, 0) I figured out how to insert the object as a graphic Dim oProvider 'GraphicProvider service. oProvider = createUnoService(com.sun.star.graphic.GraphicProvider) Dim oProps(0) as new com.sun.star.beans.PropertyValue oProps(0).Name = URL oProps(0).Value = sURL REM Returns a graphic object from the URL to the graphic. oTheme.insertGraphicByIndex(oProvider.queryGraphic(oProps()), 0) Apparently, a large collection of available clipart exists in SVG format. I installed the SVG importer from here: http://www.ipd.uni-karlsruhe.de/~hauma/svg-import/ I looked at the API, and it looks like I can insert a draw document directly: http://api.openoffice.org/docs/common/ref/com/sun/star/gallery/XGalleryTheme.html I tried it using this code: Dim oDoc Dim ImportArgs(0) As New com.sun.star.beans.PropertyValue ImportArgs(0).Name = FilterName ImportArgs(0).Value = draw_svg_import oDoc = StarDesktop.LoadComponentFromURL(sURL, _blank, 0, ImportArgs()) If NOT IsNull(oDoc) AND NOT IsEmpty(oDoc) Then oTheme.insertGraphicByIndex(oDoc, 0) oDoc.close(True) End If A -1 is returned, which means that the image was not added (I can also see that the image is not added). If you want to run the entire macro, it will be here until I resolve this problem (at which point, I will likely move it someplace on my macros page). http://www.pitonyak.org/OOoGalleryImport.odt -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Should a key event listener be called for the Ctrl key?
Christoph Lupp wrote: Hi Andrew, perhaps there is an misunderstanding. You wrote in your question to the dev mail list: Pressing a combination with the Ctrl key worked as expected, and the Ctrl key was properly indicated in the attributes. But a combination of CTRL with another key also don't work on my computer. That's my problem. Only pressing the CTRL-Key is not important for me, I need the possibility to check the combination of CTRL with (for example) the arrow-keys (UP, DOWN, LEFT, RIGHT). Christoph, I tested with Ctrl+1, Alt+1, and Ctrl+Alt+1 and the modifier for Control showed for these. The same is true for the arrow keys. Well, I only tested Ctrl+up_arrow because you said that the arrows do not work for you. Please note that I am using Fedora-7, the 64 bit version. I see the bit 2 in the modifier for a control key. The combination of ALT with another key works on my computer. Many thanks for your help Lupo P.S.: Do you know the xray-tool, is this a possibility for me? Yes, I think that you should install and use the xray tool. I wrote an object inspector before xray existed, and I still do use it because I prefer my inspector for some things. Over-all, however, XRay is certainly a better object inspector. You should be able to install and use it with no problem. I consider it highly recommended. Zitat von Andrew Douglas Pitonyak [EMAIL PROTECTED]: My opinion is that this is a bug! I can ask on the dev mail list! Christoph Lupp wrote: -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Re: [gsl-dev] Re: [api-dev] Should a key event listener be called for the Ctrl key?
Thanks for that excellent reply! (Philipp, I copied you on BCC to make certain you would receive my thanks even if you do not monitor the list). Philipp Lohmann wrote: Hi, Modifiers alone do not per se generate a key event in vcl for years but a specialized KeyModChange (modifier changed) event. This is not bound to the awt implementation, so I guess it is not available to any awt customer. Moreover key mod change is not dispatched on every modifier change, but only on key releases. This peculiar behaviour has its origin in the rather unique feature that lead to the implementation of KeyModChange, namely the explicit distinction that the left or right shift key was pressed and then released. This action switches the writing direction. The fact that you get a key input for Alt is a side effect due to the duplicate role of Alt as KEY_MENU which is native on Windows and emulated on other platforms. So currently you don't get key events for modifiers, only for modified keys. Only on Windows you get a key event for Alt pressed as actually a side effect. Kind regards, pl - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]