Re: [api-dev] Re: OOo Basic Specification
Curtis Clauson wrote: Jürgen Schmidt wrote: Hi Curtis, no, there is no specification available. Only the existing online help and the docu in the DevGuide. When you find bugs in both kind of documentation, you can easy help us by submitting an issue for the problem. The Community will owe it to you Juergen Thanks Juergen. Unfortunately, it is difficult to submit issues when you have no idea if the behavior is a bug or part of an unknown and undocumented design. The community would reap far more benefit if an OOo Basic language specification were a live document in the scripting project documentation section. Well, first you search the the issues to see if it has already been filed. You can post here and ask. You can create an issue and have them tell you that it is not an issue. I have found the people who deal with these things to be very polite, even when I am wrong and waste their time (which happens on occassion). Most of the bugs that I bothered to submit for the code have been fixed. -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.sxw My Macro Book: http://www.hentzenwerke.com/catalog/oome.htm Free Info: http://www.pitonyak.org/oo.php - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Python in 1.9.74
Ian Laurenson wrote: I have put together a uno package that contains a Python component. The component uses the os module. The package installs and runs fine 1.1.4. In 1.9.74 (for Linux - Mandrake 10.1) I get the following error message when installing the package via: Tools Package Manager... My Packages (need to select OpenOffice.org packages and then reselect My Packages for the add button to become active) Add... select the file. (com.sun.star.uno.RuntimeException) { { Message = pythonloader: couldn't find core lement pythonloader.Loader, Context = (com.sun.star.uno.XInterface) 0x0 } } Do I need to package the uno file differently or is there a bug or ...? The file is available from: http://qa.openoffice.org/issues/show_bug.cgi?id=41011 Thanks, Ian I have also seen this while trying to install some of Ian's really cool and very useful things -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.sxw My Macro Book: http://www.hentzenwerke.com/catalog/oome.htm Free Info: http://www.pitonyak.org/oo.php - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[api-dev] How to create a database in OOo 2.0?
I am so close, I can smell it, but it does not work. Any comments on the steps that I am missing... I think that I need to set default keys and that sort of thing... The following macro tries to create a databsae document... Sub NewDB Dim sDBUrl As String 'URL of a New Database document. Dim sTableName As String 'The name of the table to creat. Dim oDoc 'The newly created database document. Dim oTable'A table in the database. Dim oTables Dim oDescriptor Dim oCols Dim sName As String sDBUrl = private:factory/sdatabase sTableName = Address sName = ConvertToURL(C:\OODB\Address01.odb) 'First, create the database document and set the database type oDoc = StarDesktop.loadComponentFromURL(sDBUrl,_blank,0,Array()) oDoc.Name = sName oDoc.URL = sdbc:embedded:hsqldb REM Logically, I expect that I can call create instance on the database REM document. Unfortunately, this is not correct. oTables = oDoc.getTables() If (oTables.getCount() 1) Then oTable = oTables.createInstance(com.sun.star.sdbcx.Table) oCols = oTable.getColumns() oDescriptor = oCols.createDataDescriptor() oDescriptor.IsNullable = 0 oDescriptor.Precision = 50 oDescriptor.Name = LastName oDescriptor.Type = 12 oDescriptor.TypeName = VARCHAR oCols.appendByDescriptor(oDescriptor) REM I do not have to create a new descriptor, I can use the existing one. REM This makes things easier if I add similar columns. oDescriptor.Name = FirstName oCols.appendByDescriptor(oDescriptor) oDescriptor.Name = Address oDescriptor.IsNullable = 1 oDescriptor.Precision = 200 oCols.appendByDescriptor(oDescriptor) oDescriptor.Name = City oDescriptor.Precision = 50 oCols.appendByDescriptor(oDescriptor) oDescriptor.Name = StateOrProvince oCols.appendByDescriptor(oDescriptor) oDescriptor.Name = PostalCode oDescriptor.Precision = 20 oCols.appendByDescriptor(oDescriptor) oDescriptor.Name = PhoneNumber oDescriptor.Precision = 30 oCols.appendByDescriptor(oDescriptor) oDescriptor.Name = FaxNumber oCols.appendByDescriptor(oDescriptor) oDescriptor.Name = MobileNumber oCols.appendByDescriptor(oDescriptor) oDescriptor.Name = DateUpdated oDescriptor.Precision = 0 oDescriptor.Type = 91 oDescriptor.TypeName = DATE oCols.appendByDescriptor(oDescriptor) oDescriptor.Name = CountryOrRegion oDescriptor.Precision = 50 oDescriptor.Type = 12 oDescriptor.TypeName = VARCHAR oCols.appendByDescriptor(oDescriptor) oTables.insertByName(sTableName, oTable) End If oDoc.store() End Sub -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.sxw My Macro Book: http://www.hentzenwerke.com/catalog/oome.htm Free Info: http://www.pitonyak.org/oo.php - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] CDbl function
Sevastian `seva` Foglia wrote: I found where problem is: environment variable LANG on linux. If LANG is [EMAIL PROTECTED] this macro Sub Main Dim sVal as String sVal = 0,30 print CDbl(sVal) End Sub return 0 If LANG is not set macro return correct value 0,3 Perhaps you should add this to the issue so that they can reproduce the problem... Note: In OOo option Locale is set to Italian (Italy) Although it is a hack, perhaps you can change the , to a ., and then use Val to convert the number rather than CDbl. -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.sxw My Macro Book: http://www.hentzenwerke.com/catalog/oome.htm Free Info: http://www.pitonyak.org/oo.php - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Problem with insertDocumentFromURL
Cristian Fonti wrote: Andrew Douglas Pitonyak ha scritto: Cristian Fonti wrote: Hi to all, i have a problem using the method insertDocumentFromURL: when i use it to insert some formatted text (font size, font color,etc...) from another document, in the destination file appear at the top of the document 2-3 blank row... the code snipplets is: xTextDocument = (XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, xcomponent); xText = xTextDocument.getText(); TextCursor=xText.createTextCursor(); xd=(XDocumentInsertable) UnoRuntime.queryInterface(XDocumentInsertable.class,TextCursor); xd.insertDocumentFromURL(file:///C:/file1.rtf,loadProps); TextCursor=xText.createTextCursor(); xd=(XDocumentInsertable) UnoRuntime.queryInterface(XDocumentInsertable.class,TextCursor); xd.insertDocumentFromURL(file:///C:/file2.rtf,loadProps); If i add 3,4,5,6 documents the number of white rows increase... Please someone help me Thanks Cristian Fonti I ran the following test: Dim sURL$ Dim oText Dim oCurs sURL = file:///andrew0/home/andy/film.txt oText = ThisComponent.getText() oCurs = oText.createTextCursor() oCurs.gotoStart(False) oCurs.insertDocumentFromURL(sURL, Array()) The film.txt file, contains NO extra spaces. I did NOT see the problems that you mention. Notice that I did use the 2.0 Beta. I suspect that margins from the RTF file are inserted, but this is ONLY a guess. What happens with your code when you sue text files with NO top or bottom margins? To correct the problem, i have insert TextCursor.gotoEnd(false); after the insertDocumentFromURL Another Question: it's possibile to insert some text (a string) between two documents RTF that i import with insertDocumentFromURL Thanks Cristian Fonti Use something similar to the following: oCursor.getText().insertString(oCursor, text to insert, False) -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.sxw My Macro Book: http://www.hentzenwerke.com/catalog/oome.htm Free Info: http://www.pitonyak.org/oo.php - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Page size and Page format
Cristian Fonti wrote: Hi to all, what is the property in Java Api to set the Page size(A4,A3...) and the Page Format (Landscape,Portrait)/Allignment in a Writer Document??? I use this code: XStyleFamiliesSupplier StyleFam = (XStyleFamiliesSupplier) UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, xTextDocument); XNameAccess StyleFamNames = StyleFam.getStyleFamilies(); XNameAccess PageStyles = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class,StyleFamNames.getByName(PageStyles)); XStyle xStyle = (XStyle) UnoRuntime.queryInterface(XStyle.class,PageStyles.getByName(Standard)); XPropertySet xPropertySetStyle = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xStyle); i try to use: xPropertySetStyle.setPropertyValue(PrinterPaperTray,com.sun.star.view.PaperOrientation.LANDSCAPE); but nothing... Please someone help me. Thanks Cristian I think that you must set the mode in the page style. You are setting the paper tray that should be used, but I expected you to set the IsLandscape property Sub TestLandScape Dim oCurs Dim oPStyle Dim oPStyles oCurs = ThisComponent.getCurrentController().getViewCursor() oPStyles = ThisComponent.getStyleFamilies().getByName(PageStyles) oPStyle = oPStyles.getByName(oCurs.PageStyleName) Print State of landscape = oPStyle.IsLandscape End Sub -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.sxw My Macro Book: http://www.hentzenwerke.com/catalog/oome.htm Free Info: http://www.pitonyak.org/oo.php - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] hidden/show OpenOffice
You might want to consider simply locking the controllers... :-) The XWindow interface should support the SetVisible(boolean) method. The problem is that if a document is loaded hidden, there are some things that are apparently NOT initialized so setting the document visible after loading might cause a problem. At least this used to be the case. Bob Crothers wrote: Hi We have a Java application which runs OpenOffice. There are times when we want OpenOffice in the background and there are times when we want OpenOffice to have the focus. We have trouble with OpenOffice taking the focus away from our Java application when we do not want it to have the focus. How do I show a window after setting the Hidden property to true in the call to loadComponentFromURL? Is there some other way of hiding and showing OpenOffice which Im not aware of? Thanks Bob Crothers -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.sxw My Macro Book: http://www.hentzenwerke.com/catalog/oome.htm Free Info: http://www.pitonyak.org/oo.php - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[api-dev] Re: [users] 1.9.95 script calling Calc built-in functions
The returned object is typically a global object, so if you dispose it, then you can not get a new one until you restart OpenOffice.org. I found this while playing with some database stuff. Jahn, Ray (R.) wrote: Thanks for the advice provided by Kohei. I found useful content in both the DeveloperGuide and api.openoffice.org/docs/.../XFunctionAccess.html. I now have a few more questions regarding the proper memory management. Would appreciate advice on more reading assignment. Is the object returned by createUnoService() a local object? A global object? An object pointer (handle, in MS jargon)? Is disposal operation needed to prevent memory leakage? Can the same service be created multiple times, due to successvie calls from sheet cells to the user script routine? Would there be efficiency concern if the same service is created repetitively? (related questions on object integrity and memory management go on). Thanks again. Ray -Original Message- From: Kohei Yoshida [mailto:[EMAIL PROTECTED] Sent: Sunday, April 24, 2005 03:44 PM To: dev@sc.openoffice.org; Jahn, Ray (R.) Subject: 1.9.95 script calling Calc built-in functions I've posted a solution to a similar question in the past, which you can find here: http://sc.openoffice.org/servlets/ReadMsg?list=devmsgNo=1391 ... (snipped) HTH, Kohei - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.sxw My Macro Book: http://www.hentzenwerke.com/catalog/oome.htm Free Info: http://www.pitonyak.org/oo.php - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[api-dev] Re: [users] 1.9.95 script calling Calc built-in functions
Jahn, Ray (R.) wrote: Thanks to the explanation by Andrew Douglas Pitonyak and Mathias Bauer. Scope: global vs. local vs. any other Are all objects returned by CreateUnoService() global objects and therefore not to be disposed of by users? If the answer is dependent on the exact service requested, is there a documentation specifying which are global and which are other types? I tried the Developers Guide, version 2.0, and a few OO mail lists. Not much luck so far. One might argue that the situation is worse than you thought, because it is not just CreateUnoService that can return a global object :-) I looked in the Developer's Guide regarding a Database Context and I found the following: From the API perspective, these functions are mirrored in the com.sun.star.sdb.DatabaseContext service. The database context is a container for data sources. It is a singleton, that is, it may exist only once in a running OpenOffice.org API instance and can be accessed by creating it at the global service manager of the office. In case you missed it, it says that the object is a singleton. This means that there is only one. The correct way to dispose of this object is probably to call dispose(). Of course, there is only one so if you do choose to call dispose(), then there will not be any instances of this object. You will rarely use the dispose method. If you obtain a connection, you should close() the connection. The only time that you are likely to use dispose would be for content. For example, you might choose to dispose of some text content that is inserted in a document to make it go away. I usually use a different method to specifically remove the text content, however. FunctionAccess: Is the FunctionAccess service object returned by CreateUnoService() a pointer to a singleton object, that is, the actual singleton FunctionAccess service object? What options do you have to remove FunctionAccess? If you do not see a way to return or close it, then it is probably a global object :-) Lets test and see... Sub CheckObjects Dim obj1 Dim obj2 obj1 = CreateUnoService(com.sun.star.sheet.FunctionAccess) obj2 = CreateUnoService(com.sun.star.sheet.FunctionAccess) If EqualUnoObjects(obj1, obj2) Then Print The objects are the same Else Print The objects are NOT the same End If End Sub The same object is returned each time, so probably yes. The Developer's Guide has an example and the object is NOT removed afterwards, so there is probably only one... Memory management (leakage): Is the memory automatically reclaimed (at an unspecified time) when the service objects go out of scope? Is the memory management guideline independent of the script languages (Basic, Java-BeanShell, etc.) For the singleton objects, they will not be released until OOo is closed. The point at which the memory used to reference to the object is released will be dependent on the language that you use and when garbage collection occurs. This is probably more clearly defined in C++ than in say Java, which can pretty much garbage collect when it wants to. I have no idea what happens to a text table that is created but never inserted into a document or an instance of a user defined data type that is dynamically created. There is no concern for memory leakage if all service objects returned by CreateUnoService() are mere pointers (handles) to the real (global) service objects. Efficiency: The overhead of CreateUnoService() becomes noticeable when the repetition approaches 10 - 100 (1 million) in Basic on MS Windows 2000. As does the call to the routine that performs the work. Regards, ' --- example code in OO Basic 1.9.95 option explicit ' simulate repetitive calls from sheet cells to CreateUnoService() ' assume 10 - 20 calls to built-in sheet functions to satisfy one cell request ' assume the same number of calls to CreateUnoService() due to the partition of algorithm logic Sub test_01() dim ii as long, cnt as long, err as long cnt = 100 for ii = 0 to cnt step 1 err = call_sheet_functions() next msgbox( call_sheet_functions() repeats cnt ) End Sub function call_sheet_functions() as long Dim oFunction as variant oFunction = CreateUnoService(com.sun.star.sheet.FunctionAccess) ' data processing section, call sheet built-in functions call_sheet_functions = 0 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.sxw My Macro Book: http://www.hentzenwerke.com/catalog/oome.htm Free Info: http://www.pitonyak.org/oo.php - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Problems with Page Style
No comment on use in Java, but Cristian Fonti wrote: Hi to all, i have a problem with the Api: I generate a new Writer document, with a Java procedure, with import others documents with the method insertDocumentUrl. Now, i would to use different styles for the header of right and left pages (in the left pages, i would that the text will be left-align, in the right, right-align). I'm able to create a style and manage it, but i don't know how to set the different between right and left pages... If you look at the PageStyle service: http://api.openoffice.org/docs/common/ref/com/sun/star/style/PageStyle.html You will notice that you can set the PageStyleLayout, which determines this... http://api.openoffice.org/docs/common/ref/com/sun/star/style/PageStyleLayout.html Also, look at the TextPageStyle, and notice that there are header and footer objects that you can set. You would typically set the left and right align of the contained text based on a Paragraph style, but you can certainly hard code the values in the text object itself. How can i do it in Java??? Thanks to all Cristian Fonti - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.sxw My Macro Book: http://www.hentzenwerke.com/catalog/oome.htm Free Info: http://www.pitonyak.org/oo.php - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] new text document from selction by API
Marc Santhoff wrote: Hi, I need to make a new writer doc from another wroter docs selection. In this case the clipboard cannot be used because the target doc has to stay hidden (no dispatch with hidden docs). How can this be done? TIA, Marc Tricky! You might try something like save the document as a new document and delete everything that is NOT selected... -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.sxw My Macro Book: http://www.hentzenwerke.com/catalog/oome.htm Free Info: http://www.pitonyak.org/oo.php - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] How to insert and remove annotation?
Liao Yu wrote: Hi, We can hide and show annotations in a text document via OOo API, but how can we insert or remove one with API? Regards, Yu An annotation is just a text field, you can remove it as any other text field. -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.sxw My Macro Book: http://www.hentzenwerke.com/catalog/oome.htm Free Info: http://www.pitonyak.org/oo.php - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Sequence of Texttables
Martin Thoma wrote: Hello! I have a text-document which contains some tables: Table1 (Named MyTable) Table2 (Named My 2nd Table) I copy+paste (executeDispatch) Table1 some times into the document: Table1 (Named MyTable) NewTable (Named Table 4) NewTable (Named Table 5) NewTable (Named Table 6) NewTable (Named Table 7) Table2 (Named My 2nd Table) What I need is to access the NewTables in the right order. I tried to use getTextTables, because I thought it returns the tables in the order they are in to document, but it gives: Table1 (Named MyTable) Table2 (Named My 2nd Table) NewTable (Named Table 4) NewTable (Named Table 5) NewTable (Named Table 6) NewTable (Named Table 7) I coulnd't rely on the table-name, because I don't know which tables are already inside the document. My idea now is to store all table-names before the copy+paste, use getTextTables and compare the names with the tables-names I stored - but I have to be sure that the first table I get will be the first I inserted (Table 4) and not some other of the new tables (like Table 6). Will this ALWAYS be the case? Regards Martin If I understand your problem correctly, you want to enumerate the text tables in the order that they are contained in the document. Is this correct? If so, remember that TextTables are stored as a paragraph, so you will find them while enumerating paragraphs. Sub EnumerateTextTablesInOrder Dim oEnum Dim s$ Dim oPar oEnum = ThisComponent.getText().createEnumeration() Do While oEnum.hasMoreElements() oPar = oEnum.nextElement() If oPar.supportsService(com.sun.star.text.TextTable) Then s = s oPar.getName() CHR$(10) End If Loop MsgBox s, 0, Text Tables End Sub -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.sxw My Macro Book: http://www.hentzenwerke.com/catalog/oome.htm Free Info: http://www.pitonyak.org/oo.php - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Calc Outline and cell address
I also was unable to find anything, and I did search and inspect... Laurent Godard wrote: Hi all, i play with calc Outline and experiences some troubles 1- on a sheet, using showDetail and hideDetail hideDetail works even if only the adresse one cell of the range is used as argument showDetail needs the whole range address though Is it normal ? How can i use the showDetail with knowing only on cell of the group 2 when i'm on a cell, is there any method to know if it belongs actually to a group and retreive the bounds of it ? Didn't find anything at range, sheet and component level :( Thanks in advance Laurent -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.sxw My Macro Book: http://www.hentzenwerke.com/catalog/oome.htm Free Info: http://www.pitonyak.org/oo.php - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Re: newbie drawing question
My guess is that this fails because you are using a macro to create a draw page in a Draw document, but you are running the macro in a Write document. A write document contains only one draw page, not multiple draw pages. In other words, you can not create a new draw page in a Write document (I should verify this, but I believe it to be true). Senthilkumar Mehalingam wrote: Hi All, Thanks Andrew for your reply. I am trying to create a macro which like MS Word's draw table for the Draw application allows the user to specify the number of shapes and then creates them. Just as Word's draw wizard asks for number of rows and columns I want to ask for number of shapes and their hierarchy(say 1 root and two children) and creating them accordingly. I looked at DannysDrawPowerTools-2003-08-09.01 and Andrew's book on OO macros and got a lot of help and this is what I managed to do using both of them but am still having problems I cannot comprehend and would appreciate any assistance. After I click the Create button in the dialog I get an error in createDrawPages function /// Private oDialog As Object Sub StarPolyDialog() Copyright (c) 2003 Danny Brewer ' Make sure this library, with its dialog is loaded which I checked DialogLibraries.LoadLibrary( Standard ) REM I loaded the libraries and created a Dialog box of name ShapeDlg 'having a REMnumeric 'field Count in it. I assgned the macro Sub btnCreateStarOrPoly_Clicked to REMbe assigned to the create button when it is clicked but inspite of the fact the REM rectangels are not created. I traced the running step by step by the Single Step but REM am not able to trace the error ' Create the dialog object. oDialog = createUnoDialog( DialogLibraries.GetByName( Standard ).GetByName( ShapeDlg ) ) ' Display the dialog. ' This routine call does not return until the dialog is dismissed. oDialog.Execute() ' Execution does not reach this point until the dialog is dismissed. End Sub ' This is called when the user clicks the Create button on the dialog box. Sub btnCreateStarOrPoly_Clicked ' Get the values of the controls in the dialog box. ' nNumSides = oDialog.getControl( Count ).getValue() ' and pass it to the Builder function Builder( nNumSides) End Sub Sub Builder( num ) ' Make sure the TurtleGraphics library of modules is loaded. which I did. BasicLibraries.LoadLibrary( TurtleGraphics ) drawFirstGraphic(num) End Sub Sub drawFirstGraphic(num) Dim oPage 'Page on which to draw Dim oShape 'Shape to insert Dim oPoint 'Initial start point of the line Dim oSize 'Width and height of the line Dim i% 'Index variable Dim n% 'Number of iterations to perform oPage = createDrawPage(ThisComponent, new Test Draw, True) ' create a new Drawing pag n = num ' and try to create Rectangles in it For i = 0 To n oShape = ThisComponent.createInstance(com.sun.star.drawing.RectangleShape) oPage.add(oShape) oShape.setPosition(createPoint(1000,1000)) oShape.setSize(createSize(4000, 1000)) oShape.setString(box 1) oShape.Shadow = True oShape = ThisComponent.createInstance(com.sun.star.drawing.RectangleShape) oPage.add(oShape) oShape.setPosition(createPoint(6000, 1000)) oShape.setSize(createSize(4000, 1000)) oShape.setString(box 2) oShape.Shadow = True oShape.ShadowXDistance = -150 oShape.CornerRadius = 100 Next i End Sub Function CreatePoint(ByVal x As Long,ByVal y As Long) As com.sun.star.awt.Point Dim oPoint oPoint = createUnoStruct( com.sun.star.awt.Point ) oPoint.X = x oPoint.Y = y CreatePoint = oPoint End Function Function CreateSize(ByVal x As Long,ByVal y As Long) As com.sun.star.awt.Size Dim oSize oSize = createUnoStruct( com.sun.star.awt.Size ) oSize.Width = x : oSize.Height = y CreateSize = oSize End Function Function createDrawPage(oDoc, sName$, bForceNew As boolean) As Variant Dim oPages 'All of the draw pages Dim oPage 'A single draw page Dim i% 'General index variable oPages = oDoc.getDrawPages() If oPages.hasByName(sName) Then REM If we require a new page then delete REM the page and get out of the for loop. If bForceNew Then oPages.remove(oPages.getByName(sName)) Else REM Did not request a new page so return the found page REM and then get out of the function. createDrawPage = oPages.getByName(sName) Exit Function End If End If REM Did not find the page, or found the page and removed it. REM Create a new page, set the name, and return the page. oPages.insertNewByIndex(oPages.getCount()) oPage = oPages.getByIndex(oPages.getCount()-1) oPage.setName(sName) createDrawPage = oPage End Function /// Thanks a lot. From: Andrew Douglas Pitonyak [EMAIL PROTECTED] Reply-To: dev@api.openoffice.org To: dev@api.openoffice.org CC: Senthilkumar Mehalingam [EMAIL PROTECTED], [EMAIL
Re: [api-dev] Browsing the source code
I typically download the source code and then I use a text search on the whole thing. Of course, the whole thing is more than 1GB I think, so on my computer, this can take a long time. Especially since sometimes I search for the wrong thing :-( Senthilkumar Mehalingam wrote: Hi All, I want to see how the cut,paste,undo,redo functionalities are implemented in OO.org. If anybody could point me to the specific files and modules in which they are implemented I would highly appreciate that. I want to know if Design Patterns are used in implementing them or not. If not I would like to try to implement it. I would appreciate any help and advice. Thanks - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.sxw My Macro Book: http://www.hentzenwerke.com/catalog/oome.htm Free Info: http://www.pitonyak.org/oo.php - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Browsing the source code
The real problem is finding the specific code that you want. For example, I decided to look at the Writer specific code so I looked here: sw/source/core/frmedt and I searched for the word Clipboard. Probably NOT what you want. I also some stuff off of the core directories. In fact, I saw many many references. I expect that each portion will have its own handling code. Senthilkumar Mehalingam wrote: Hi All, Thanks Andrew for your reply. I did as you told but I cannot find the functions(cut,paste,undo,redo) inspite of a thorugh search as searching for cut finds .cpp files which have cut as a middle word in them and searching for cut finds no .cpp files. I got the source from http://openoffice.mirror.wrpn.net/stable/1.1.4/OOo_1.1.4_source.tar.gz and am not sure if I did get the right version or I needed to get the most recent one from the CVS Server. The unzipped version had 116 cpp source files. Are the functions implemented in some other files having a different extension or am I making a mistake. I would appreciate any help. Sincerely Senthil From: Andrew Douglas Pitonyak [EMAIL PROTECTED] Reply-To: dev@api.openoffice.org To: dev@api.openoffice.org Subject: Re: [api-dev] Browsing the source code Date: Wed, 27 Jul 2005 22:02:58 -0400 I typically download the source code and then I use a text search on the whole thing. Of course, the whole thing is more than 1GB I think, so on my computer, this can take a long time. Especially since sometimes I search for the wrong thing :-( Senthilkumar Mehalingam wrote: Hi All, I want to see how the cut,paste,undo,redo functionalities are implemented in OO.org. If anybody could point me to the specific files and modules in which they are implemented I would highly appreciate that. I want to know if Design Patterns are used in implementing them or not. If not I would like to try to implement it. I would appreciate any help and advice. Thanks - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.sxw My Macro Book: http://www.hentzenwerke.com/catalog/oome.htm Free Info: http://www.pitonyak.org/oo.php - 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.sxw My Macro Book: http://www.hentzenwerke.com/catalog/oome.htm Free Info: http://www.pitonyak.org/oo.php - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] [CPHennessy] [users] Print order '4; 1; 2; 3'?
Mathias Röllig wrote: Am 10.08.2005 09:47 schrieb Turbo Fredriksson: I don't know, why you would specifify the pageorder. If you print pages 1-8 with the 'brochure' option, you will get a 'book' with 8 pages in the right order. Also pages 9-16, 17-32 aso. Oki, so which variable do i set for this? I can set the 'PaperOrientation' (using 'com.sun.star.view.PaperOrientation.LANDSCAPE'), the 'PaperFormat' (using 'com.sun.star.view.PaperFormat.A4'), 'PageRows' and 'PageColumns'. But I can't figure out a way to specify to print in brochure format... I think you need http://api.openoffice.org/docs/common/ref/com/sun/star/text/PrintSettings.html#PrintProspect greetings Mathias What is Prospect Printing? Until now I have never heard anyone indicate that they know what it means. You recommend prospect printing, so I assume that you do know. Previously, I spent a lot of time trying to figure out what it is... -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.sxw My Macro Book: http://www.hentzenwerke.com/catalog/oome.htm Free Info: http://www.pitonyak.org/oo.php - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Active cell from selection
Jayant Balraj Madavi wrote: Hi, I create a Range from Selection. how do I find the active cell ?? uno::Reference frame::XModel xModel( m_xDesktop-getCurrentComponent(), uno::UNO_QUERY ); uno::Reference table::XCellRange xRange( xModel-getCurrentSelection(), ::uno::UNO_QUERY); Active cell is the last cell that is shown with white border . Regards, Jayant If you have a copy of my free macro document, read the section titled: Get the active cell and ignore the rest #6.5.1.Get%20the%20active%20cell%20and%20ignore%20the%20rest%7Coutline -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.sxw My Macro Book: http://www.hentzenwerke.com/catalog/oome.htm Free Info: http://www.pitonyak.org/oo.php - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] [CPHennessy] [users] Print order '4; 1; 2; 3'?
Marc Santhoff wrote: Am Samstag, den 13.08.2005, 17:21 -0400 schrieb Andrew Douglas Pitonyak: Mathias Röllig wrote: [...] I think you need http://api.openoffice.org/docs/common/ref/com/sun/star/text/PrintSettings.html#PrintProspect greetings Mathias What is Prospect Printing? Until now I have never heard anyone indicate that they know what it means. You recommend prospect printing, so I assume that you do know. Previously, I spent a lot of time trying to figure out what it is... Since I'm german and OOo / SO itself is based on work of primarily german developers I suppose there may be a translation error that has nerver been corrected, JDictionary tells me the german word Prospekt stands for: leaflet folder prospectus (?) catalogue Do these tranlations make any sense? Marc Wow, Thanks. Yes, this makes a lot of sense. While I was writing my macro book, I wanted to document these options, but I did not know what prospect printing was. I posted some questions on the mailing lists, but I received no answers to this particular question. It is nice to finally find out what it means! Thanks again! -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.sxw My Macro Book: http://www.hentzenwerke.com/catalog/oome.htm Free Info: http://www.pitonyak.org/oo.php - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[api-dev] CSV file opens a write document
I am writing an extensive database and macro document here: http://www.pitonyak.org/database/OOoBaseBinaryFields.odt I have a macro that demonstrates how to connect to flat files using macros. My macro generates the data, loads the data into a Calc document using the scalc: Text - txt - csv (StarCalc) filter, and then connects to the flat file and the Calc document as a data source. This is all for learning, of course. On Windows, a Calc document is opened, and on my Linux box, a Write document is opened. Does this make any sense at all? If you download the document listed above, search for Read Fixed Width File, which is listing 31 on page 65. There is a button that you can click on, which will automatically run the macro, which is also displayed in the text -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.sxw 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 doesn't run
In my opinion, yes. If you want the default behavior, then do not attache anything else to it, otherwise, do it all in your own code. Douglas Staas wrote: Ok, so due to the rescheduling of threads, sometimes an OK button's events get fired as expected and sometimes the dialog is closed before those events get run? Does this mean that binding code to OK button events is generally a bad idea with Open Office? I'm just trying to understand. This subtle quirk appears to be unique to Open Office. Is this something that'll be addressed some day? thanks doug An OK button performs a default action. so, you think that it should only do what you told it to, but in reality, it is ALSO doing the default OK action, which you did not expect because you did not know what an OK button was. Douglas Staas wrote: Thanks to Paolo and everyone else who's offered ideas. Paolo's fix worked. 11.3.3 appears to be very general. I don't see how it applies to this specific scenario. Then again, perhaps understanding the difference between an OK button and a Default type button would help. If so, where could I find documentation on that? ie: Where can I read about OK buttons causing a dialog to close before associated events are fired? Thanks, again. I'm sure I'll have more questions as I digest this and proceed. doug Hi Douglas, Alle 19:16, giovedì 10 novembre 2005, Douglas Staas ha scritto: My questions keep piling up. If this isn't the right place to ask them, where should I seek answers/useful documentation? If this is the right place to ask them, what do I need to do to engage in a dialog about these issues? * Macros don't run when a 2nd OO file is open unless the macro editor is open. When will this be resolved? I don't want to dig into details but ony let you know that IMHO your macro is not well conceived and perhaps your problem is only a side effect of that. 1) You have manually binded the events keyPressed and MousButton-pressed to the SetAllTexts subroutine 2) You have set the OK Button as Button Type = OK I think that your problem is due to the fact that the 2) causes the dialog to close before the events has been raised. This is the normal behaviour and you can find a detailed explanation of that in the DevGuide at: 11.3.3Special Behavior of OpenOffice.org Basic Rescheduling BTW the DevGuide shows an example that covers exactly your situation. However, my suggestion is to remove the binding of events and modify your PromptForValues as shown below. Sub PromptForValues DialogLibraries.LoadLibrary( SlaySysLibrary ) oDialog = CreateUnoDialog( DialogLibraries.SlaySysLibrary.SlaysysDialog ) If oDialog.Execute() = 1 Then SetAllText() End If end Sub hope that helps PaoloM - 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.sxw 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] macro graphics handling is wonky
Douglas Staas wrote: Attached is my newest binder cover Draw file. It prompts the user for a client logo and it displays the image in 4 locations. Sometimes all 4 locations are updated, sometimes 1, sometimes 2, 3 or ever zero. When less then 4 locations are updated, you can save the file, close it, reopen it and magically all 4 locations show the correct image. What's going on here? I'm running the same code with the same input and getting different results. ... actually, it looks like the attachment is too large for this list. In general, attachements are highly discouraged. Assume that I add a 1MB attachemt and send my email. Many people will recieve this one MB attachement. The majority do not care to see the attachement. Many of the people use a dial-up connection. So, most mailing lists automatically remove attachements. The preferred method is for you to host the document somewhere and then provide a link to it. That said, there are many possible reasons for this particular problem. Sometimes, I have found that making some very simple rediculous change causes the problem to go away. Without looking at the macro, this is very difficult to say. I can think of a few things off hand that MIGHT cause the problem. You create the object in such a way that the SAME object (or some shared portion is the same) is used in all places. When you save the document, only a reference is saved, and on opening, an entirely new copy is properly created for each object. I had this really strange problem while using arrays and strings. It turned out that I was storing a reference to a string each time that I added it to the array . When I was finished, every instance had the same value because they all referenced the same variable instance. It was very strange indeed. If possible, create the smallest simplest macro that demonstrates the problem, and then if the macro is short, simply add it here. If not, then create it in a document such that it can demonstrate the problem and then post the document and send a link to the list. -- 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] disposing of macros
Douglas Staas wrote: i'm reposting this question: What is meant by provide for disposal when the document is closed? Where could I find this in the documentation? Well, where did you read this? It is not possible to answer without context. No wait, I just ran a GOOGLE search on the exact phrase and found this: http://www.mail-archive.com/dev@api.openoffice.org/msg01793.html Next time, quote enough of the message to provide context. Here is the entire quote: Sounds like everything is being loaded into memory and not being released when you close your original document. Does your on Open Event macro provide for disposal when the document is closed ? One possible reading of this is that the open document has resources, such as graphics, or pointers, or some kind of internal structures. When the document is closed, Alex is wondering if all of the document's resources are released, deleted, freed, (no longer used). Kind of like what might happen if a program opened a file and then left the file opened. You could not create and use the file again, because it would already be listed as open. I have no idea where this would be in the documentation, because it would depens on the type of resourced that might be causing the problem. One possibility might be that your macro uses a GLOBAL variable to hold a reference to a dialog. The document closes, but eh global variable still exists and can therefore not be referenced again. If this were the case, then loading the Basic IDE might cause these resources to be released. This is, of course, all speculation on my part, espcially since I have not seen your macro. -- 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] disposing of macros
I was able to extract one attachement from this email, so I took a look at it. I noticed a few unusual things. Consider the OK button. The OK Button is listed as type OK button, NOT as a default button. Because of this, when you click on the button, an event is automatically fired, that will CLOSE the dialog. The button also has some events tied to things such as key press and mouse click. There are two issues with this. First, you should probably just use the when initiating event, which covers both of the cases. Second, when you click on the button, it is supposed to do two distinct things. The OK action, because this is an OK button, and use your events. Which is done first? Which is done second? The primary problem here, is that the OK action changes the state of the dialog. If these fire in a multi-threaded way, I have no idea which will be finished first and what the result will be. It is likely to be timing related and unreliable. Off hand, I reccomend that you use one method or the other. In other words, either let the action close the dialog, or perform the actions AFTER the dialog has closed if OK was used to close the dialog. Using the methods that you describe, are likely to leave things in an unfinished state. Douglas Staas wrote: i'm reposting this question: What is meant by provide for disposal when the document is closed? Where could I find this in the documentation? Subject: [api-dev] disposing of macros From: [EMAIL PROTECTED] (Douglas Staas) Date: Thu, 10 Nov 2005 20:34:16 + To: dev@api.openoffice.org To: dev@api.openoffice.org Subject: Re: [api-dev] macro doesn't run From: [EMAIL PROTECTED] (Douglas Staas) Date: Thu, 10 Nov 2005 19:16:52 + To: dev@api.openoffice.org To: dev@api.openoffice.org - 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] disposing of macros
Douglas Staas wrote: The button also has some events tied to things such as key press and mouse click. I have since changed this. I removed the event bindings and simply call the code like so: If oDialog.Execute() = 1 Then SetAllText() End If Also, you hit the nail on the head. My macro uses a GLOBAL variable to hold a reference to the dialog. What should I do to clean up when closing the document? Or is this situation to be avoided altogether? thanks doug It looks like you are well on your way! There is a difference between GLOBAL, PRIVATE, and PUBLIC when they are placed at the module level. If you ONLY need the variable to be visible in one module, then use PRIVATE. If you require it outside of the current module, then use PUBLIC. In general, you should only use GLOBAL if you want the variable to live for a long long long long time (I outline the differences in my book, but lack the desire to fully explain it here and now); an example would be for an event listener, which needs to hold its value between runs. Think of Global as similar to static. I must be careful on my wording here... You could perhaps explicitly set variables declared outside of a sub or function to be NULL after you use them. Douglas Staas wrote: i'm reposting this question: What is meant by provide for disposal when the document is closed? Where could I find this in the documentation? Well, where did you read this? It is not possible to answer without context. No wait, I just ran a GOOGLE search on the exact phrase and found this: http://www.mail-archive.com/dev@api.openoffice.org/msg01793.html Next time, quote enough of the message to provide context. Here is the entire quote: Sounds like everything is being loaded into memory and not being released when you close your original document. Does your on Open Event macro provide for disposal when the document is closed ? One possible reading of this is that the open document has resources, such as graphics, or pointers, or some kind of internal structures. When the document is closed, Alex is wondering if all of the document's resources are released, deleted, freed, (no longer used). Kind of like what might happen if a program opened a file and then left the file opened. You could not create and use the file again, because it would already be listed as open. I have no idea where this would be in the documentation, because it would depens on the type of resourced that might be causing the problem. One possibility might be that your macro uses a GLOBAL variable to hold a reference to a dialog. The document closes, but eh global variable still exists and can therefore not be referenced again. If this were the case, then loading the Basic IDE might cause these resources to be released. This is, of course, all speculation on my part, espcially since I have not seen your macro. -- 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 -- 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 graphics handling is wonky
I appreciate being able to see some code :-) Still did not get enough sleep. I sent a birth anouncement by email to family and friends before going to bed and then I started to receive telephone call after telephone call until late into the night. So, my mind is a bit clouded. I sometimes read the email to relax :-) I see immediately that you do NOT declare all of your variables. Can you add Option Explicit to the top of every module. This can be a good thing at times. If you know that you have a string variable, then declare it as a string. For objects, I usually use a Variant, which means that I do not bother to name a type. My suggestions shown below are guesses, I hope that they work. Douglas Staas wrote: Thanks. Below are some relevant code snippets. This might be related to my message titled: macro only works when there is a breakpoint. I haven't been able to reproduce this bug with a breakpoint and stepping over the code. When I step over the code, I switch between the macro window and the document window to see the behavior. I wonder if this causes some sort of a refresh that is lacking in my code? thanks doug So, try to add something like: Dim iCount As Integer Dim oShape Dim oPage Dim ShapeName As String sub x iCount = oPage.getCount For i = 0 to iCount - 1 oShape = oPage.getByIndex( i ) ShapeName = oShape.getName if ... elseIf ( ShapeName = ClientLogoBBCover ) then SizeAndPlaceGraphic( oShape, oPage, ClientLogoCover ) elseIf ( ShapeName = ClientLogoBBSpine1 ) then SizeAndPlaceGraphic( oShape, oPage, ClientLogoSpine1 ) elseIf ( ShapeName = ClientLogoBBSpine2 ) then SizeAndPlaceGraphic( oShape, oPage, ClientLogoSpine2 ) elseIf ( ShapeName = ClientLogoBBSpine3 ) then SizeAndPlaceGraphic( oShape, oPage, ClientLogoSpine3 ) end if Next end sub Hmmm, I did not know that you could declare your variables this way. Hmmm. Very interesting. First, note that you use the variable iCount in BOTH subroutines, but you NEVER declared them. Are you using an evil global variable, or one whose scope is limited to the subroutine? Declare EVERY variable so that you know its scope. How about the oShape objects? Try changing the heading as follows: sub SizeAndPlaceGraphic(BoundingBox, oPage, ByVal GraphicName$ ) At least change the GraphicName declaration if the others do not work. sub SizeAndPlaceGraphic( BoundingBox as SvxShapeText, oPage as SdDrawPage, GraphicName ) Dim oSize As New com.sun.star.awt.Size Dim oPos As New com.sun.star.awt.Point dim oGraphic iCount = oPage.getCount For i = 0 to iCount - 1 oShape = oPage.getByIndex( i ) ShapeName = oShape.getName if (ShapeName = GraphicName) then oGraphic = oShape end if next if isEmpty( oGraphic ) then oGraphic = ThisComponent.createInstance( com.sun.star.drawing.GraphicObjectShape ) oGraphic.Name = GraphicName oPage.add(oGraphic) end if cUrl = ConvertToUrl( oDialog.GetControl( FileControl1 ).Text ) if ( cUrl = ) then rem No client logo selected oSize.height = 0 oSize.width = 0 oGraphic.setSize( oSize ) else maxW = BoundingBox.size.width maxH = BoundingBox.size.height oGraphic.SetPosition( BoundingBox.position ) oGraphic.GraphicURL = cUrl OriginalAspectRatio = oGraphic.Graphic.SizePixel.width / oGraphic.Graphic.SizePixel.height oSize.height=maxH oSize.width= OriginalAspectRatio * oSize.height if ( oSize.width maxW ) then Shrink = maxW / oSize.width oSize.width = maxW oSize.height = oSize.height * Shrink end if oGraphic.setSize(oSize) end if end sub Douglas Staas wrote: Attached is my newest binder cover Draw file. It prompts the user for a client logo and it displays the image in 4 locations. Sometimes all 4 locations are updated, sometimes 1, sometimes 2, 3 or ever zero. When less then 4 locations are updated, you can save the file, close it, reopen it and magically all 4 locations show the correct image. What's going on here? I'm running the same code with the same input and getting different results. ... actually, it looks like the attachment is too large for this list. In general, attachements are highly discouraged. Assume that I add a 1MB attachemt and send my email. Many people will recieve this one MB attachement. The majority do not care to see the attachement. Many of the people use a dial-up connection. So, most mailing lists automatically remove attachements. The preferred method is for you to host the document somewhere and then provide a link to it. That said, there are many possible reasons for this particular problem. Sometimes, I
Re: [api-dev] Strange effect when accessing TextCursor objects
Alexej Kryukov wrote: Hi, in my projects I often have to iterate through text portions in OOo Writer text documents. So, when trying to adapt my older programs to OOo 2.0 I noticed the following strange problem. Let's take for example the following macro (which basically does nothing, just iterates through text portions in order to access their String property): Sub IteratePortions () oDoc = ThisComponent oText = oDoc.Text oEnum = oText.createEnumeration () Do While oEnum.hasMoreElements oPara = oEnum.nextElement oParaEnum = oPara.createEnumeration () Do While oParaEnum.hasMoreElements () oPortion = oParaEnum.nextElement Select Case oPortion.TextPortionType Case Text oPortionCursor = oText.createTextCursorByRange (oPortion, 0) sPortionString = oPortionCursor.getString () Case Else End Select Loop Loop End Sub If you run this macro on a document which is long enough, you may notice that each time getString() is called, a progress indicator is shown for few time, with a label which says (if I managed to make it out) Exporting document. There is no such effect, if I call the getString() method for the portion itself (i. e. execute oPortion.getString ()), instead of creating an intermediate text cursor. However, intermediate text cursors are often needed to workaround other OOo bugs, even if creating them doesn't look necessary :( This exporting looks quite irritating, not only because it significantly slows execution of my functions, but also because it doesn't allow me to create my own status bar indicator (which may be quite important for long operations). So, can anybody explain, which sort of exporting is performed here, and how can I avoid it? If anyone cares, I have verified this behavior. I modified the macro a bit so that it works on documents containing things such as TextTabels without crashing... Sub IteratePortions() Dim oText Dim oEnum Dim oPara Dim oParaEnum Dim oPortion Dim oPortionCursor Dim sPortionString$ oText = ThisComponent.getText() oEnum = oText.createEnumeration () Do While oEnum.hasMoreElements oPara = oEnum.nextElement If oPara.supportsService(com.sun.star.text.Paragraph) Then oParaEnum = oPara.createEnumeration () Do While oParaEnum.hasMoreElements () oPortion = oParaEnum.nextElement Select Case oPortion.TextPortionType Case Text 'oPortionCursor = oText.createTextCursorByRange (oPortion, 0) oPortionCursor = oText.createTextCursorByRange (oPortion) sPortionString = oPortionCursor.getString () Case Else End Select Loop End If Loop 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] getFormDocuments() in StarBasic
Daniel Brunner wrote: I am trying to get a reference to the forms related to a DataSource in StarOffice 8.0. How ca I transpose the following code snippet to StarBasic : public static void openFormInDesignMode(XMultiServiceFactory _rMSF) throws com.sun.star.uno.Exception { XNameAccess xNameAccess = (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, _rMSF.createInstance(com.sun.star.sdb.DatabaseContext)); // we use the first datasource XDataSource xDS = (XDataSource)UnoRuntime.queryInterface( XDataSource.class, xNameAccess.getByName( Bibliography )); XConnection con = xDS.getConnection(,); XFormsSupplier xSup = (XFormsSupplier)UnoRuntime.queryInterface(XFormsSupplier.class, xDS); XNameAccess xForms = xSup.getFormDocuments(); if ( xForms.hasByName(Form1) ){ Object form = xForms.getByName(Form1); // to hold ref { XComponentLoader loader = (XComponentLoader)UnoRuntime.queryInterface(XComponentLoader.class, xForms); PropertyValue[] args = new PropertyValue[]{PropertyValue(OpenMode,0,openDesign) ,PropertyValue(ActiveConnection,0,con)}; XComponent formdocument = loader.loadComponentFromURL(Form1,,0,args); } } } My idea was : dbContext = CreateUnoService( com.sun.star.sdb.DatabaseContext ) xds= dbContext.getByName( Bibliography ) login = password = con = maSource.getConnection( login, password ) xForms = xds.getFormDocuments() Rem --- nok !!! Thanks in advance for your help. Daniel - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Download this document http://www.pitonyak.org/database/AndrewBase.odt And search for getFormDocuments(). Off hand, I do not think that you can get the form documents from a database document, not from the database. Sub InspectFormsInDB Dim oContext Dim oDB Dim oForms oContext = CreateUnoService( com.sun.star.sdb.DatabaseContext ) oDB = oContext.getByName( Bibliography ) oForms = oDB.DatabaseDocument.getFormDocuments() 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Integer Division?
Felix E. Klee wrote: Am Mittwoch, 14. Dezember 2005 12:11 schrieb Laurent Godard: 11 \ 3 = 3 I couldn't find documentation for this operator in the online help (1.1.3). How come? or fix(11/3) Well this probably uses a floating point number as an intermediary, which could introduce numerical errors. This is not what I want. Anyway, thanks for your help so far. I believe that it is not documented. I documented them in my book by reading the source code -- 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 do I generate an Error?
Felix E. Klee wrote: In the online documentation and in a book that I have at hand (Open Office Programmierung by Rene Martin) I find explanation for handling errors. But, what I'd like to know is: * How can I let my code *generate* errors? * If generating errors manually is possible, how do I set the error number and the error message? While writing my book, my intial reading of the specification was that you could CAUSE a specific error to be generated. I was never able to figure out how. It is my opinion that this is because I misunderstood the documentation. When I read it again, (as in now) I see why I thought that, but you can not cause the error unless you really do cause the error. -- 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] getData() and getDataArray() do not work on text tables.
Should getData() and getDataArray() work on a text table? I tested this on windows and linux using 2.01 release candidates. Create a text document and add a single text table. Add some data to the text table. Use at least two rows and two columns. Now, run this macro Dim oTable oTable = Thiscomponent.getTextTables().getbyIndex(0) Dim oData() : oData() = oTable.getDataArray() Dim a() : a() = oData(1) Print a(1) MsgBox Join(a(), CHR$(10)) Print oTable.getCellByPosition(1, 1).getString() The returned data is ALWAYS 0. Now, change getDataArray() to getData(). The returned values are still zero. What am I missing? -- 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 apply a paragraph style to a XTextTableCursor?
Peter Eberlein wrote: Hi, in a former StarOffice version the following worked properly: oTableCursor = oTable.createCursorByCellName(oTable.CellNames(0)) oTableCursor.ParaStyleName = MyStyle Contrary to a normal XTextCursor this does not work in 2.0 anymore. According to the api the service css.text.TextTableCursor includes the service css.style.ParagraphProperties with the missing property ParaStyleName. Any hints? Regards Peter If you need to modify ALL of the paragraphs, I have macros that do this sort of thing. I am making updates to my macro document that descirbe how to work with text tables. I think that the version on my web site (which is not really the latest) has something that formats a table to match the OOo Authors format. In case it is too old, here is the macro REM * BASIC * Option Explicit Sub Main FormatTable() End Sub Sub FormatTable(Optional oUseTable) Dim oTable Dim oCell Dim nRow As Long Dim nCol As Long If IsMissing(oUseTable) Then oTable = ThisComponent.CurrentController.getViewCursor().TextTable Else oTable = oUseTable End If If IsNull(oTable) OR IsEmpty(oTable) Then Print FormatTable: No table specified Exit Sub End If 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 For nRow = 0 To oTable.getRows().getCount() - 1 For nCol = 0 To oTable.getColumns().getCount() - 1 oCell = oTable.getCellByPosition(nCol, nRow) If nRow = 0 Then oCell.BackColor = 128 SetParStyle(oCell.getText(), OOoTableHeader) Else SetParStyle(oCell.getText(), OOoTableText) If nRow MOD 2 = 1 Then oCell.BackColor = -1 Else REM color is (230, 230, 230) oCell.BackColor = 15132390 End If End If Next Next ' Inspect(oTable) ' Inspect(oCell) End Sub Sub SetParStyle(oText, sParStyle As String) Dim oEnum Dim oPar oEnum = oText.createEnumeration() Do While oEnum.hasMoreElements() oPar = oEnum.nextElement() If opar.supportsService(com.sun.star.text.Paragraph) Then 'oPar.ParaConditionalStyleName = sParStyle oPar.ParaStyleName = sParStyle End If Loop End Sub Be warned that this macro will ONLY work for a simple text table because of the way that it enumerates all of the cells. -- 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] Optional Parameters in Starbasic function call
Andrew Jensen wrote: Question, I attempted to write a function with the following declaration: function findCodeVal( RegDSName as String, _ TableName as String, _ SrchColName as String, _ SrchFor as variant, _ RetColName as String, _ optional isCaseSensitive as boolean, _ optional isFuzzy as boolean, _ optional aConn as variant, _ optional UserName as String, _ optional Password as String) _ as variant However, with this declaration, isMissing returns False for every optional parameter, even when none have been pass in to functions call. When I changed the order of the parameters to: function findCodeVal( RegDSName as String, _ TableName as String, _ SrchColName as String, _ SrchFor as variant, _ RetColName as String, _ optional UserName as String, _ optional Password as String, _ optional isCaseSensitive as boolean, _ optional isFuzzy as boolean, _ optional aConn as variant) _ as variant Then isMissing returned the correct response in all cases. So is this because of the Boolean types as optional parameters? If so, can any one tell me what other rules apply to order of optional parameters. Thanks in advance. Andrew 'Drew' Jensen (Apologies if this is a second posting, I sent this yesterday but it does not seem to have made it for some reason) As of version 1.0.3.1, IsMissing will fail with Optional parameters if the type is not Variant and the missing optional parameter is represented by two consecutive commas. I first investigated this behavior after speaking with Christian Anderson [EMAIL PROTECTED] This is issue 11678 in issuezilla. The issue was closed with a note that it needed to be created under a different topic, which I know because I just went back and checked the status. This may be related Then again, I have not verified that the original issue is still a problem. -- 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] Optional Parameters in Starbasic function call
Laurent Godard wrote: Hi Bernard, The bug was reported in IZ 30500. In versions 1.1.x and 2.0.1 it is still not corrected and not even documented, so it should not have status RESOLVED and FIXED. perhraps reopen the bug and mark it as regression in keywords where are optional parameters located in the source code ? I can perharps have a look Laurent This is from OOo 2.0 RC 2 so it might have changed basic/source/runtime/methods.cxx RTLFUNC(IsMissing) { if ( rPar.Count() 2 ) StarBASIC::Error( SbERR_BAD_ARGUMENT ); else // #57915 Missing wird durch Error angezeigt rPar.Get( 0 )-PutBool( rPar.Get(1)-IsErr() ); } -- 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: [users] Macro in 1.1.4 does not work in 2.0
Miguel Quirós wrote: Thank you very much for your answer. As I told, I am not expert in writing macros and I am just using the things that I can see are used by the macro recorder (the dispatcher) and try to adapt them to my needs. From your answer, I deduce that there are methods easier to use than the dispatcher (.searchString). Unfortunately, they are not easier, because you need to learn how things work inside of OOo. Many examples are available that can be adapted to the problems that you want to solve. Also, sometimes the macro recorder works for what you want, and sometimes it does not. I have a free macro document that contains many examples (this is different than my book): http://www.pitonyak.org/AndrewMacro.odt There are so many resources that I can not easily list them all. There are code snippets with examples: http://codesnippets.services.openoffice.org/ There is a forum that you can search: http://www.oooforum.org/ My needs are to search all occurrences of a determinate string in a document You did not say why you wanted to search for every occurrence of the string. Ignoring the replace it part, here is an example that finds all occurrences: Take a look at my macro document in section 7.14 titled Search And Replace. Does this help at all? and, in some cases just replace it by another simple string (in which case I see that there is something called .replaceAll that may be useful and easy to use) and in other cases by something more complicated like putting a new string with special symbols, superindexes , etc in it, in this case perhaps .replaceAll cannot do all the work. As suggested, I am sending this message also to dev@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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Re: [users] Macro in 1.1.4 does not work in 2.0
Your welcome. Be certain to ask if you have other questions. Miguel Quirós wrote: El mar, 06-06-2006 a las 21:38 -0400, Andrew Douglas Pitonyak escribió: Miguel Quirós wrote: Thank you very much for your answer. As I told, I am not expert in writing macros and I am just using the things that I can see are used by the macro recorder (the dispatcher) and try to adapt them to my needs. From your answer, I deduce that there are methods easier to use than the dispatcher (.searchString). Unfortunately, they are not easier, because you need to learn how things work inside of OOo. Many examples are available that can be adapted to the problems that you want to solve. Also, sometimes the macro recorder works for what you want, and sometimes it does not. I have a free macro document that contains many examples (this is different than my book): http://www.pitonyak.org/AndrewMacro.odt Thank you again. I hava had a quick look and it looks like a magnificent work (I imagine that the book will be even more magnificent). I will need to find some time to grab at least the fundamentals of what it is said here. There are so many resources that I can not easily list them all. There are code snippets with examples: http://codesnippets.services.openoffice.org/ There is a forum that you can search: http://www.oooforum.org/ My needs are to search all occurrences of a determinate string in a document You did not say why you wanted to search for every occurrence of the string. Ignoring the replace it part, here is an example that finds all occurrences: Take a look at my macro document in section 7.14 titled Search And Replace. Does this help at all? At first sight, I think I have found something useful. The result of findFirst used as result.end can be used for findNext as starting point to find the next occurence. Anyway, it is clear I would need to find time to learn more, not easy ... In any case, thanks a lot for your help. and, in some cases just replace it by another simple string (in which case I see that there is something called .replaceAll that may be useful and easy to use) and in other cases by something more complicated like putting a new string with special symbols, superindexes , etc in it, in this case perhaps .replaceAll cannot do all the work. As suggested, I am sending this message also to dev@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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Mapping of the UNO type hyper in StarBasic
Paolo Mantovani wrote: Hi Christian, sorry for my previous message. Alle 09:20, martedì 20 giugno 2006, Christian Junker ha scritto: Hi Paolo, I have the same problems as you have here. I guess there is no other way than using CreateUnoValue. [...] 2) using CreateUnoValue might be too difficult for some to see or use at first sight, thus making hyper a real type as single, double etc. would make things more comfortable for the programmer. Would be good to hear what Andreas Bregas thinks about that. I only want to add that using CreateUnoValue is a workaround if you have to pass an hyper to an API method, but does not helps when you must get an hyper. I've also tried with the css.script.Converter but without any result, so any suggestions are welcome thank you Paolo Are you saying that you do not know how to convert the returned value to something that is usable when it is returned? I noticed that some other types could not be created using any other method... I think that Byte was one of them... -- 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] Best way to find or identify redline
Assuming a simple text document, I can enumerate text sections. I thought that I could find red line text by checking for the RedlinePortion service, but I can not. The example below finds redline sections by checking for the existance of a specific property in the property set information object. Am I missing something? Sub MainRedLine Dim oPar Dim oParsEnum Dim oTextElementEnum Dim oSection Dim s$ ' Enumerate over the paragraphs. oParsEnum = thisComponent.getText().createEnumeration() 'or thisComponent.getCurrentSelection().getByIndex(i).createEnumeration() ' loop over all text elements Do While oParsEnum.hasMoreElements() oPar = oParsEnum.nextElement REM Search through paragraphs and ignore the rest. If oPar.supportsService(com.sun.star.text.Paragraph) Then oTextElementEnum = oPar.createEnumeration() Do While oTextElementEnum.hasMoreElements() oSection = oTextElementEnum.nextElement REM Sections with redlines will support the following properties: 'STRING/void RedlineAuthor = Andrew Pitonyak 'STRING/void RedlineComment = 'OBJECT/void RedlineDateTime = [Can not convert Object to a string] 'STRING/void RedlineIdentifier = -371500180 'ARRAY/void RedlineSuccessorData = Empty 'OBJECT/void RedlineText = Empty 'STRING/void RedlineType = Insert REM Surprisingly, this is NEVER true, but I do find redline sections. If oSection.supportsService(com.sun.star.text.RedlinePortion) Then MsgBox The current block contains a redline. End If REM This will find them, however. Very odd indeed! If oSection.getPropertySetInfo().hasPropertyByName(RedlineType) Then MsgBox (2) The current block contains a redline. End If Loop End If Loop 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Best way to find or identify redline
And another question with redlines If I iterate over the redlines, how can I accept or reject them? Sub MainIterateRedLine Dim oDoc Dim oViewCursor Dim oContWin Dim oRedLines, oRedLine Dim k% Dim lRet As Long Dim sDum$ oDoc = ThisComponent oViewCursor = oDoc.CurrentController.ViewCursor oContWin = oDoc.CurrentController.Frame.ContainerWindow oRedLines = oDoc.Redlines for k=0 to oRedLines.Count-1 oRedLine = oRedLines.getByIndex(k) oViewCursor.gotoRange(oRedLine.RedlineStart, false) oViewCursor.gotoRange(oRedLine.RedlineEnd, true) sDum = oRedLine.RedlineType oViewCursor.String Chr(10) sDum = sDum by: oRedLine.RedlineAuthor Chr(10) sDum = sDum at: oRedLine.RedlineDateTime.Hours : oRedLine.RedlineDateTime.Minutes oRedLine.RedlineDateTime.Day . oRedLine.RedlineDateTime.Month . oRedLine.RedlineDateTime.Year Chr(10) sDum = sDum Chr(10) Accept (yes), decline (no), or leave as is (cancel) ? Chr(10) call oContWin.toFront() ' just for convenience when running from Basic IDE lRet = msgbox(sDum, 3, Tracking changes ...) select case lRet case 6 'yes case 7 'no end select next k 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Searching Tables or Cell Ranges in the Writer
If you are using a macro to search, you can indicate where a search will begin. For example, you can specify that the search should start at the first position of the text object in the first cell of a table. Or, you could start searching from the last point before the text table begins. You can then check the end position to see if it is after the text table of interest. There are, of course, certain difficulties when comparing ranges that are NOT in the same text object, but that is related to the details of solving the problem, rather than answering your high-level question. Kent Gibson wrote: Thanks for the suggestion. Something like that might work. Perhaps I should explain the problem a bit more. I am having some quirky problems inserting images into tables. So I thought I would render my table and instead of inserting images, I would insert some text (ie a url) then when I finished the table I would replace the text with an image (with a macro). The idea works great. But search only seems to work at the document level. The idea won't work at the very end of rendering, becuase I need to render the table (which is in a frame) and then replace the images and then check to see how big my frame is, because these frames will be chained. I could render a table, do my search and throw out previosly found tables (this may be computationally very expensive at the end of a large document). Or render my table, and do a forward search. But I am not sure if either of these will work. --- Peter Eberlein [EMAIL PROTECTED] wrote: Hi Kent, Kent Gibson schrieb: Is there any way to do a search using XSearchable in writer and set the scope to something other than the document, for example a table or a cell range? I am pretty sure it works in calc with cell ranges, but I can't get it work in the writer for anything but a document. why not checking the found-objects (which are XTextRanges), if they support one of the XTextTable-Services? Peter - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com - 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] Searching Tables or Cell Ranges in the Writer
Well, consider this macro which sets all instances starting from the first table to bold. I did not attempt to see if the cursor had left the table for this macro. Sub SearchTable Dim oDescriptor, oFound Dim oTable Dim oCell REM Get the FIRST text table oTable = ThisComponent.getTextTables().getByIndex(0) oCell = oTable.getCellByName(A1) 'Inspect(oTable) 'Exit Sub oDescriptor = ThisComponent.createSearchDescriptor() With oDescriptor .SearchString = one .SearchWords = False .SearchCaseSensitive = False End With REM oFound = ThisComponent.findFirst(oDescriptor) oFound = ThisComponent.findNext( oCell.getText().getStart(), oDescriptor) Do While Not IsNull(oFound) oFound.CharWeight = com.sun.star.awt.FontWeight.BOLD oFound = ThisComponent.findNext( oFound.End, oDescriptor) Loop End Sub I will create a new section in my macro document and demonstrate a complete working example that searches ONLY the first text table. This will be titled Search only the first text table. I will finish this and post it before I go to sleep tonight. Kent Gibson wrote: odd, I tried everything I could to tell the search where to begin. I am happy to use macros to get this working. Do you have an example? I want to tell the search to begin at an arbitrary table, first cell is perfectly ok for me. --- Andrew Douglas Pitonyak [EMAIL PROTECTED] wrote: If you are using a macro to search, you can indicate where a search will begin. For example, you can specify that the search should start at the first position of the text object in the first cell of a table. Or, you could start searching from the last point before the text table begins. You can then check the end position to see if it is after the text table of interest. There are, of course, certain difficulties when comparing ranges that are NOT in the same text object, but that is related to the details of solving the problem, rather than answering your high-level question. -- 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 width of column in texttable in basic
Download my free macro document and find section 8.7 titled Column Widths Martin Thoma wrote: Hello! I just want to set the width of a cell in a writers texttable (OO 2.0.2, Windows). I found this message http://api.openoffice.org/servlets/ReadMsg?list=devmsgNo=3446 and adapted it to basic: oDesktop = createUnoService( com.sun.star.frame.Desktop ) Dim mArgs(0) As New com.sun.star.beans.PropertyValue oDoc = oDesktop.loadComponentFromURL(file:///e:/test.ott, _blank, 0, mArgs()) oTable = oDoc.getTextTables.getByName(Table2) oT = oTable.TableColumnSeparators oT(1).Position = 123 oTable.TableColumnSeparators = oT But OO says that oT(1) has no member Position. Is it just too hot today for me to get the clue or what could be the problem? Has somebody a working example in basic to set the width of a texttable-column in writer? Regards Martin - 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] Apply Styles to Cell Range
Kent Gibson wrote: Is there any way to apply a style to a range of cells in the writer? As far as I can see you have to extract the XText from every cell, create a cursor and then apply the style. no? Kent, you never mentioned what type of style that you want to set. In my free macro document, I demonstrate setting the paragraph style for every cell in a row in a text table... Find the section titled Formatting a simple text table -- 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] LoadComponentFromURL using an XInputStream in Basic
I am using OOo 2.0.3 on Linux FC4. I store a binary file into a database - Base document if it matters. First I tried to use a stream: oStatement.setBinaryStream(2, oStream, oStream.getLength()) The error message said that there was an error from the ODBC driver stating that the stream was NULL. I found that the following works: lLen = oStream.getLength() ReDim oData(0 To lLen-1) oStream.readBytes(oData(), lLen) oStatement.setBytes(2, oData(), lLen) I can extract the data from my database to a file. oSimpleFileAccess.writeFile(sURL, oStream) Rather than writing the file to disk, I would prefer to load the file directly. Dim oProp(0) As New com.sun.star.beans.PropertyValue oProp(0).Name = InputStream : oProp(0).Value = oStream REM oProp(1).Name = ReadOnly: oProp(1).Value = True REM oProp(2).Name = FilterName : oProp(2).Value = writer8 StarDesktop.LoadComponentFromUrl(private:stream, _blank, 0, oProp()) When I try this, however, soffice locks up and I have to manually kill soffice. The closest that I could find to a solution is in Java, but it uses a com.sun.star.lib.uno.adapter.ByteArrayToXInputStreamAdapter The speculation is that the XInputStream does not support XSeekable. http://joott.cvs.sourceforge.net/joott/jooconverter2/src/net/sf/jooreports/openoffice/converter/OpenOfficeDocumentConverter.java?view=markup -- 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] LoadComponentFromURL using an XInputStream in Basic
snip snip snip :-) It can be solved ... if you implement an UNO Service which accepts a Sequence sal_Int8 as IN parameter and returns an XSeekable/XInputStream as result. Such service can be used in Java, C++, Basic, Phyton etcpp. Currently I do not know if such help service still exists .-) OK, for now, I will consider this as NOT possible unless I implement the service to do this myself. b) Use another filter or dont specify any filter so loadComponentFromURL() can search for it's own one. I have tried specifying, and not specifying, the filter. Then it does not depend on your content. It seams realy a problem of your non-seekable stream. But I don not understand then why the office locked up. Normaly the call loadComponentFromURL() should return without loading this content. May be you can provide some stacks (produced with an attached debugger), which shows us, where the office is hanging ? That I can try to do... I use Linux (FC4). If you have any advise on which debugger to attempt to use, that would perhaps be useful. I will see if I can figure out how to do this with gdb. It looks like I can attach it to a running process! Wahooo! I did not know that I could do that! Here is the first time with the macro started from the IDE: (gdb) bt #0 0xf74517a5 in rtl_uStringbuffer_insert_ascii () from /opt/openoffice.org2.0/program/libuno_sal.so.3 #1 0xf21375a5 in ?? () from /opt/openoffice.org2.0/program/libgcc3_uno.so #2 0xf2137a23 in ?? () from /opt/openoffice.org2.0/program/libgcc3_uno.so #3 0xf213a81c in ?? () from /opt/openoffice.org2.0/program/libgcc3_uno.so #4 0xf213aabd in ?? () from /opt/openoffice.org2.0/program/libgcc3_uno.so #5 0xed3908e5 in component_getFactory () from /opt/openoffice.org2.0/program/reflection.uno.so #6 0xf24c8a97 in SbUnoObject::Notify () from /opt/openoffice.org2.0/program/libsb680li.so #7 0xf7cfb6f9 in SfxBroadcaster::Broadcast () from /opt/openoffice.org2.0/program/libsvl680li.so #8 0xf2506add in SbxVariable::Broadcast () from /opt/openoffice.org2.0/program/libsb680li.so #9 0xf250309e in SbxValue::SbxValue$base () from /opt/openoffice.org2.0/program/libsb680li.so #10 0xf25065b9 in SbxVariable::SbxVariable$base () from /opt/openoffice.org2.0/program/libsb680li.so #11 0xf24eb0a1 in SbiRuntime::FindElement () from /opt/openoffice.org2.0/program/libsb680li.so #12 0xf24eb346 in SbiRuntime::StepELEM () from /opt/openoffice.org2.0/program/libsb680li.so #13 0xf24e2938 in SbiRuntime::Step () from /opt/openoffice.org2.0/program/libsb680li.so #14 0xf24b4dbd in SbModule::Run () from /opt/openoffice.org2.0/program/libsb680li.so #15 0xf24b508e in SbModule::Notify () from /opt/openoffice.org2.0/program/libsb680li.so #16 0xf7cfb6f9 in SfxBroadcaster::Broadcast () from /opt/openoffice.org2.0/program/libsvl680li.so #17 0xf24b7733 in SbMethod::Broadcast () from /opt/openoffice.org2.0/program/libsb680li.so #18 0xf250309e in SbxValue::SbxValue$base () from /opt/openoffice.org2.0/program/libsb680li.so #19 0xf25065b9 in SbxVariable::SbxVariable$base () from /opt/openoffice.org2.0/program/libsb680li.so #20 0xf24eb0a1 in SbiRuntime::FindElement () from /opt/openoffice.org2.0/program/libsb680li.so #21 0xf24eb625 in SbiRuntime::StepFIND () from /opt/openoffice.org2.0/program/libsb680li.so #22 0xf24e2938 in SbiRuntime::Step () from /opt/openoffice.org2.0/program/libsb680li.so #23 0xf24b4dbd in SbModule::Run () from /opt/openoffice.org2.0/program/libsb680li.so #24 0xf24b508e in SbModule::Notify () from /opt/openoffice.org2.0/program/libsb680li.so #25 0xf7cfb6f9 in SfxBroadcaster::Broadcast () from /opt/openoffice.org2.0/program/libsvl680li.so #26 0xf24b7733 in SbMethod::Broadcast () from /opt/openoffice.org2.0/program/libsb680li.so #27 0xf250376f in SbxValue::Get () from /opt/openoffice.org2.0/program/libsb680li.so #28 0xebc1a643 in basicide_choose_macro () from /opt/openoffice.org2.0/program/libbasctl680li.so #29 0xebc09a12 in ?? () from /opt/openoffice.org2.0/program/libbasctl680li.so #30 0xebc09afd in ?? () from /opt/openoffice.org2.0/program/libbasctl680li.so #31 0xebc0cb56 in ?? () from /opt/openoffice.org2.0/program/libbasctl680li.so #32 0xebc05d29 in ?? () from /opt/openoffice.org2.0/program/libbasctl680li.so #33 0xebbfdcf2 in ?? () from /opt/openoffice.org2.0/program/libbasctl680li.so #34 0xf27ce04d in SfxDispatcher::GetDisableFlags () from /opt/openoffice.org2.0/program/libsfx680li.so #35 0xf27ce382 in SfxDispatcher::_Execute () from /opt/openoffice.org2.0/program/libsfx680li.so #36 0xf27ce422 in SfxDispatcher::_Execute () from /opt/openoffice.org2.0/program/libsfx680li.so #37 0xf27f6033 in non-virtual thunk to SvxSearchItem::Notify(com::sun::star::uno::Sequencertl::OUString const) () from /opt/openoffice.org2.0/program/libsfx680li.so #38 0xebb8cf3c in ?? () #39 0xeb15feb8 in ?? () #40 0xebb8f8f0 in ?? () #41 0xff8526d0 in ?? () #42 0xf27f5ff0 in non-virtual thunk to
Re: [api-dev] How can I concatenate a stream word collection
aloizio wrote: Hi My goal is to store the merged document on a database as a byteArray. I am not being able to do this. Then I am trying to stored the merged document on disk and after moving it to the database. Do you know where I can find one example about this? In my current code I want to read a lot of word document from database as an InputStream array, but I am not being able to merge them into another document In AndrewBase.odt, I have an example that opens a document, creates a byte array, and dumps that into a database. I attempted to stream the data into the database, but streaming did not work. I had to obtain a byte array from the stream and then store that into the database. -- 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] field value in header not related to view cursor
I wrote a simple macro to create a text like representation of a Write document containing a header and/or footer with the current page number. The view cursor traverses the pages, extracting header, text, and footer. The interesting thing for me was that the header/footer content is static and does not update based on the location of the view cursor (footer contained the page number). In retrospect, I can understand why this is so, but I was also a bit surprised. Any comments on this behavior? Sub ExportText() Dim oDoc Dim oCurs Dim oVC Dim oStyles Dim oStyle Dim s$ oDoc = ThisComponent oStyles = oDoc.StyleFamilies.getByName(PageStyles) oVC = oDoc.currentController.getViewCursor() oVC.gotoStart(False) oCurs = oVC.getText().createTextCursorByRange(oVC) REM Assume at the top of the loop that at the start of a new page Do oStyle = oStyles.getByName(oVC.PageStyleName) oCurs.gotoRange(oVC, False) oVC.jumpToEndOfPage() oCurs.gotoRange(oVC, True) If oStyle.HeaderIsOn Then s = s oStyle.HeaderText.getString() CHR$(13) CHR$(10) End If s = s oCurs.getString() CHR$(13) CHR$(10) If oStyle.FooterIsOn Then s = s oStyle.FooterText.getString() CHR$(13) CHR$(10) End If If NOT oVC.jumpToNextPage() Then Exit Do 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] How can I concatenate a stream word collection
I was never able to insert one document into another using a stream... I can open a document using certain types of streams (Never from a stream obtained from a database), but not insert (note that I use Basic). aloizio wrote: Hi I am able to store a document like a stream into database using BLOB, but I am not able to merge the documents that are in stream format. -- 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 get paragraph from TextRange
If you can create a text cursor from a TextRange, then you can use the ParagraphCursor to jump to the start and end of the paragraph. Julien Galand wrote: Does someone know a reliable way to get the paragraph containing a TextRange (let's say it's collapsed), beside of course enumerating all paragraphs from the start of the text ? (which has linear complexity proportional to the number of paragraphs) -- 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 can I insert a header only in the first page
aloizio wrote: How can I insert a header that appear only in the first page of the document? I am using OpenOffice API, Java. You need to use a different page style for the first page and a different page style for the rest. You then enable the special header only in the first page page style. Do you understand styles well enough to implement this in styles to perform manually? After you do, then it is pretty easy to implement using the API by setting the page style on the first page. (but the first page style should set the next style to your standard page 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] How can I insert a header only in the first page
aloizio wrote: I don't understand styles well enough yet. Have you some example code? I have been working with OpenOffice API for three months. First, you need to know how to do this using the GUI. In other words, you must understand how styles work. After you understand styles and how to use them, then, and only then, should you attempt to code it using the API. If you do not understand how styles work, then understanding how to manipulate them from the API will not help. I recommend that you start with the documentation project and/or the user's guide to first learn how to use 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]
[api-dev] Create simple toolbar in basic
What are the basic steps to create a simple toolbar in basic? Assume, for example, that I desire a toolbar associated with Writer documents that supports commands such as next page, previous page, document start, etc... Must I create an addon? I assume no. If I wanted the toolbar in a specific document, I assume that I can use the documents configuration manager to create and then store the toolbar. For all Writer documents, however, I am guessing that I need to use the ConfigurationProvider service, but this is only a guess. My next guess is the layout manager, but that just seems wrong. I would love to see a simple example in Basic. -- 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] Create simple toolbar in basic
Carsten Driesner wrote: Andrew Douglas Pitonyak wrote: What are the basic steps to create a simple toolbar in basic? Hi Andrew, You don't need to create an add-on, but it would make life much easier if you just want to use built-in commands. No coding, just define the content of your toolbar in a xml file. Never done this before... I should learn how. For all Writer documents, however, I am guessing that I need to use the ConfigurationProvider service, but this is only a guess. No, that's not the way to go. You have to retrieve the module ui configuration manager and there you can change module dependent toolbars. (See Basic example below) Thanks, the example was EXACTLY what I needed In your example, you have the following code, which works: If ( oModuleCfgMgr.hasSettings( sTBURL )) Then oModuleCfgMgr.replaceSettings( sTBURL, oTBSettings ) Else oModuleCfgMgr.insertSettings( sTBURL, oTBSettings ) End If This code, however, has a problem: If ( oModuleCfgMgr.hasSettings( sTBURL )) Then 'oModuleCfgMgr.replaceSettings( sTBURL, oTBSettings ) oModuleCfgMgr.RemoveSettings( sTBURL, oTBSettings ) oModuleCfgMgr.insertSettings( sTBURL, oTBSettings ) Else oModuleCfgMgr.insertSettings( sTBURL, oTBSettings ) End If While testing, I wanted to make a toolbar go away, so I REMOVED the settings. I was no longer able to create a new toolbar with the URL of the removed toolbar. There are no errors, it simply does nothing. -- 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] How update options/configuration without restart
Use Tools Options OpenOffice.org calc General Press enter to move selection, and set a new value. Close the dialog, and the change is immediate. If I use the API, however, I must restart OOo before the change is seen. For example, Sub CheckConfigs Dim nodeArgs(0) As New com.sun.star.beans.PropertyValue Dim s$ Dim oProvider DIm oUpdateAccess REM Properties nodeArgs(0).Name = nodePath nodeArgs(0).Value = org.openoffice.Office.Calc/Input nodeArgs(0).State = com.sun.star.beans.PropertyState.DEFAULT_VALUE nodeArgs(0).Handle = -1 'no handle! REM the required Config Services s = com.sun.star.comp.configuration.ConfigurationProvider oProvider = createUnoService(s) s = com.sun.star.configuration.ConfigurationUpdateAccess oUpdateAccess = oProvider.createInstanceWithArguments(s, nodeArgs()) Print oUpdateAccess.MoveSelectionDirection = oUpdateAccess.MoveSelectionDirection oUpdateAccess.MoveSelectionDirection = 1 oUpdateAccess.commitChanges() End Sub If the MoveSelectionDirection is set to 0 (Down) using the GUI and then I use the macro to set the direction to 1 (Right), I must restart OOo to see the change. Well, the macro sees the change if I run the macro a second time. Is there a suitable method to convince OOo to recognize the change that is not a hack? -- 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 update options/configuration without restart
Niklas Nebel wrote: Andrew Douglas Pitonyak wrote: If the MoveSelectionDirection is set to 0 (Down) using the GUI and then I use the macro to set the direction to 1 (Right), I must restart OOo to see the change. Well, the macro sees the change if I run the macro a second time. Is there a suitable method to convince OOo to recognize the change that is not a hack? You can use the property MoveDirection of service com.sun.star.sheet.GlobalSheetSettings. It takes effect immediately. Niklas This is EXACTLY what I needed to know! Thanks! -- 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] Create simple toolbar in basic
Carsten Driesner wrote: Andrew Douglas Pitonyak wrote: In your example, you have the following code, which works: If ( oModuleCfgMgr.hasSettings( sTBURL )) Then oModuleCfgMgr.replaceSettings( sTBURL, oTBSettings ) Else oModuleCfgMgr.insertSettings( sTBURL, oTBSettings ) End If This code, however, has a problem: If ( oModuleCfgMgr.hasSettings( sTBURL )) Then 'oModuleCfgMgr.replaceSettings( sTBURL, oTBSettings ) oModuleCfgMgr.RemoveSettings( sTBURL, oTBSettings ) oModuleCfgMgr.insertSettings( sTBURL, oTBSettings ) Else oModuleCfgMgr.insertSettings( sTBURL, oTBSettings ) End If While testing, I wanted to make a toolbar go away, so I REMOVED the settings. I was no longer able to create a new toolbar with the URL of the removed toolbar. There are no errors, it simply does nothing. May be you have found a bug. I will check it. Just for your information, removing the configuration settings is not enough to really get rid of a toolbar. OpenOffice.org 2.0.x supports live-configuration and therefore would even show a toolbar without configuration data (the toolbar must be requested by the application code). You can see this if you use the toolbar configuration dialog via Tools - Configure - Toolbar and create a custom toolbar. You have to remove the window state of the toolbar via OpenOffice.org configuration access. Regards, Carsten I have been documenting all of this... I must remove the window state using configuration access. sigh -- 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] getCellAddress() returns garbage
Is the method getCellAddress() deprecated? I am not able to obtain valid results. For example, I ran the following macro on FC6 (with what ever came with the system, which means I am still on 2.04 with a fedora supplied build) Sub TestCellAddress Dim oCell Dim oAddress oCell = ThisComponent.Sheets(0).getCellByPosition(2, 3) oAddress = oCell.getCellAddress() MsgBox Sheet = oAddress.Sheet CHR$(10) _ Column = oAddress.Column CHR$(10) _ Row = oAddress.Row End Sub Returned: Sheet = -2268 Column = 32767 Row = -1189158716 -- 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] getCellAddress() returns garbage
Cor Nouws wrote: Hi Andrew, Andrew Douglas Pitonyak wrote: Is the method getCellAddress() deprecated? I am not able to obtain valid results. For example, I ran the following macro on FC6 (with what ever came with the system, which means I am still on 2.04 with a fedora supplied build) Sub TestCellAddress Dim oCell Dim oAddress oCell = ThisComponent.Sheets(0).getCellByPosition(2, 3) oAddress = oCell.getCellAddress() MsgBox Sheet = oAddress.Sheet CHR$(10) _ Column = oAddress.Column CHR$(10) _ Row = oAddress.Row End Sub Returned: Sheet = -2268 Column = 32767 Row = -1189158716 Returns 0, 2, 3 for me. Thus OK. And when I use oCell = ThisComponent.getCurrentSelection() I also retrieve the correct (selected) address. This with OOo 2.1 / XP So maybe your system is just in need for a little break ;-) Best wishes, Thanks for checking. I will assume that there is an issue with the version built and supplied by the FC6 AMD64 distro. I do know that it has the Novell stuff integrated, so it is not a straight OOo install. -- 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] getCellAddress() returns garbage
Laurent Godard wrote: Hi Andrew, Andrew Douglas Pitonyak a écrit : Is the method getCellAddress() deprecated? I am not able to obtain valid results. For example, I ran the following macro on FC6 (with what ever came with the system, which means I am still on 2.04 with a fedora supplied build) it at a 64 bits platform ? Laurent Yes, FC6 AMD64, standard distro, which means that it also includes the Novell stuff. -- 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] Dialogs: OK button can't call macros?
Johnny Andersson wrote: Hi again... 2007/1/24, Malte Timmermann [EMAIL PROTECTED]: This will return 0 for Cancel, something else (1) for OK. So if execute() doesn't return 0, do your stuff. One thing comes to my mind then: When dlg.execute() is finished (user clicked OK or Cancel), I can do my stuff, which is to use the data from the dialog, such as date, time and other info that the user selected, isn't that data lost when the dialog is closed? Johnny Although the dialog is closed, you can still access the dialog; only the view is gone. So, you can access the controls and extract information. Also, if you do not use an OK or Cancel button, you can still write your own button event handler that closes the dialog. This assumes, of course, that you can access the dialog from within your handler. To do this, you must store a reference to the dialog in a variable that is publically visible in your method. I would provide more information, but I really need to sleep... -- 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: Variant vs other types...
Johnny Andersson wrote: Maybe I should put it another way: Let's say that I have these lines, among others: Dim Ctl As Object Dim Doc As Object, Sheet As Object Dim A As String Dim OBDef As Double ' Or whatever, it doesn't seem to matter in this case, see further below... Doc=ThisComponent Sheet=Doc.Sheets.getByName(Blah) OBDef=DataSheet.getCellRangeByPosition(4,1,9,3).getDataArray() ' Now OBDef seems to change to Variant. You have a Calc sheet and you return a cell range based on its position. Next, you call getDataArray() on the cell range. The official return type is sequence sequence any , which means an array of arrays of variants. My opinion is that this should cause an error because an array of arrays of any should not be assigned to a double unless the type can be coerced or cast into the double type. so, you found a but (that has been around a long time) in StarBasic. I rarely think about it because it has never caused me any problems. There might be some reason for the behavior but I am not aware of the reasons. If you wanted the specific values, i expect you to write something like this: Dim oData() Dim oRow() Dim i%, j% Dim s$ s = oData() = DataSheet.getCellRangeByPosition(4,1,9,3).getDataArray() For i=LBound(oData()) To UBound(oData()) oRow() = oData(i) For j = LBound(oRow()) To UBound(oRow()) s = s CStr(oRow(j)) Next s = s CHR$(10) Next MsgBox s ' By the way, (4,1,9,3) is E2:J4. Row 2 and 3 in that spreadsheet contains numbers, row 4 contains text. A=OBDef(2,0) ' This doesn't work. See above, it is an array of arrays, this is not a two dimensional array. Okay, so far, no good. When I look at the variables with Övervakaren (in Swedish, I don't have a clue what it might be called in English, but I am talking about the tool that helps me to see the content of variables while I step through the macro, the button that allows me to select variables to watch in the Basic API thing, has a pair of glasses on it and F7 does the same thing), it seems like OBDef(2)(0) is a Variant/String. What's the difference between Variant/String and just String? A variant can hold any type. So, you have a variant that references a string. So my question is really something like this: How do I, in this meaningless example, make the content of OBDef(2,0), which is a String variable, originally some text in cell E4 in spreadsheet Blah, to be copied to A, which is an ordinary String? Does th example shown above help? If not... oRow() = oBDef(2) A = oRow(0) What I would like to achieve is to copy a CellRange to a 2-dimensional variable. Since some rows contains numbers and other contains text I though that the type Variant could be useable, but obviously not... No I really have to copy the CellRange cell by cell? What do you really want to accomplish? Do you want to copy a range of data from one location to another? If so, you can use methods to directly copy the data. I have used cheat methods such as oCellRange1.setData(oCellRange2.getData()) Another solution would perharps be to create a struct (as it's called in C), but is that possible in OpenOffice.org Basic? Yes, you can create a user defined structure/type. To quote from my AndrewMacro.odt document. 1.1. User Defined Data Types As of OOo 1.1.1, you can define your own data types. Listing 5.51: You can define your own data types. Type PersonType FirstName As String LastName As String End Type Sub ExampleCreateNewType Dim Person As PersonType Person.FirstName = Andrew Person.LastName = Pitonyak PrintPerson(Person) End Sub Sub PrintPerson(x) Print Person = x.FirstName x.LastName End Sub I gave a presentation at the 2004 OOo Conference in Berlin concerning creating advanced data types using structures. The examples are in the presentation available on my web site. Johnny -- 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: Variant vs other types...
Johnny Andersson wrote: 2007/1/29, Andrew Douglas Pitonyak [EMAIL PROTECTED]: What do you really want to accomplish? Do you want to copy a range of data from one location to another? If so, you can use methods to directly copy the data. I have used cheat methods such as oCellRange1.setData(oCellRange2.getData()) No, a function will use the data (and other data) for calculation. The function will return a value that will be written to another cell. The function will be in a loop and use three of the values (one column), different every time. Very good. I assume that you now know how to do this. Another solution would perharps be to create a struct (as it's called in C), but is that possible in OpenOffice.org Basic? Yes, you can create a user defined structure/type. To quote from my AndrewMacro.odt document. 1.1. User Defined Data Types As of OOo 1.1.1, you can define your own data types. Listing 5.51: You can define your own data types. Type PersonType FirstName As String LastName As String End Type Sub ExampleCreateNewType Dim Person As PersonType Person.FirstName = Andrew Person.LastName = Pitonyak PrintPerson(Person) End Sub Sub PrintPerson(x) Print Person = x.FirstName x.LastName End Sub Wow, I didn't know that! Now I have to rewrite everything macro and every function I've made so far..! They are not that many, on the other hand... In your example above, is the following possible? Sub ExampleCreateNewType Dim Person(100) As PersonType Person(0).FirstName = Andrew Person(0).LastName = Pitonyak PrintPerson(Person(0)) End Sub Try it, yes, it works And is the following possible? Type PersonType FirstName As String LastName As String ThingsToDo(9) As String End Type No, you can NOT have an array inside of a struct. You need to fake it: Type PersonType FirstName As String LastName As String REM You can NOT have an array inside a structure REM ThingsToDo(9) As String REM But you can fake it... ThingsToDo As Variant End Type Sub ExampleCreateNewType Dim Person As PersonType Dim aa(9) As String Person.FirstName = Andrew Person.LastName = Pitonyak Person.ThingsToDo = aa() Print UBound(Person.ThingsToDo) REM Prints 9 Person.ThingsToDo = DimArray(9) Print UBound(Person.ThingsToDo) REM Prints 9 'PrintPerson(Person) End Sub And finally, is the following possible? Type PersonType FirstName As String LastName As String End Type Type Human Properties As PersonType Friends(9) As PersonType End Type You can not have an array inside of a struct. A struct in a struct, however, is fine. And even more finally, is there something similar to pointers in OpenOffice.org Basic? I demonstrate this in the presentation I referenced. I gave a presentation at the 2004 OOo Conference in Berlin concerning creating advanced data types using structures. The examples are in the presentation available on my web site. Interesting! I'd better take a look there then! Thanks for your reply! Johnny -- 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] StarBasic - what to recommen and what to avoid?
Your structs should pass by reference unless you purposely pass them by value. see http://www.pitonyak.org/oooconf/OOoConf_2004_Macro_Presentation.sxi so, passing these should not be a performance issue. Much will be determined by how many times things are called as to what you should really do. You can create your own services, but I assume that you would want to implement these in C++ or Java, not Basic. Johnny Andersson wrote: I have a question about what is recommended to do and to avoid when writing macros with StarBasic. I think that one very convenient thing to do, is to create structs (as they are called in C/C++), such as this one mentioned in another thread a while ago: Type PersonType FirstName As String LastName As String End Type Let's say that we created a rather complex struct with hundreds of variables and other structs, like this: Type PersonType FirstName As String LastName As String Status As MyStruct . . . End Type Type MyStruct Test1 As Integer Test2 As Double Blah As MyOtherStruct . . . End Type Type MyOtherStruct . . . End Type . . . (The dots means and so on…) So, now we want to do stuff. We will create a function that needs, say two string variables. The function is only going to be used for this project, so we don't need to make it general. So here are two options that I could think of: 1: Sub Main Dim A As MyStruct Sim B As Integer A.FirstName=Johnny A.LastName=Andersson . . . B=MyFunction(A.FirstName, A.LastName) . . . End Sub Function MyFunction(A As String, B As String) As Integer Dim C As Integer . . . 'A and B are used to calculate C in some way, how is not important, it's just an example. . . . MyFunction=C End Function 2: Sub Main Dim A As MyStruct Sim B As Integer A.FirstName=Johnny A.LastName=Andersson . . . B=MyFunction(A) . . . End Sub Function MyFunction(A As MyStruct) As Integer Dim C As Integer . . . 'A.FirstName and A.LastName are used to calculate C in some way. No other variables of A are used. . . . MyFunction=C End Function One of the advantages with option 2, is that I don't need to include a lot of parameters when I call the function. In this example it was not that big difference, but sometimes I need maybe 5 or 10 parameters. On the other hand, and this is my question: Isn't option 2 more time consuming? I am not sure how this works, but if the whole structure is copied every time the function is called, I guess it will run slower. So how does it work? Are all the variables copied to the function or is that handled by a reference or something like that? Should option 2 be avoided for extremely complex structures? Or should option 1 be avoided? Can you see more (and better) options for this kind of problem? A bonus question: Is there anything like the C++ class in StarBasic? I think VB use classes too… It feels like objects works like classes. They have their own methods to handle their own variables, just like C++ classes, but can I create my own? Johnny Andersson -- 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] ImageURL in a UnoControlImageControlModel
Fernand Vanrie wrote: Need to show Embeded Images in a UnoControlImageControlModel. Giving a normal URL to the ImageURL property works fine, but Internal URL's (from embedded Images) do not works Is there a workaround ? Can a internal URL been transformed to a normal URL ? Tryed to use the Graphic-object of the Imagecontrol, but no luck, btw wathts te purpouse of the Graphic-propterty ? Thanks for any hint i think that internal URLs for graphics start with vnd.sun.star.GraphiObject:, which is probably only useful as trivia... Take a look at section 5.9.1 Convert a linked graphic to an embedded graphic. in my free macro document, there is some application that might provide a hint using the bitmap. -- 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] extension's max supported OOo version
Mathias Bauer wrote: Paolo Mantovani wrote: Hi, Alle 20:20, giovedì 22 marzo 2007, Frank Schönheit - Sun Microsystems Germany ha scritto: Hi Stephan, [...] I suppose one can think of more things which contribute to an extension's required environment, but are not guaranteed to be stable over major OOo upgrades. dispatch Url's are probably one of these things. Not necessarily. My take on dispatch URL's is that they should stay stable also except if we removed the functionality in a newer version. But even in this case the code using it would still work; you just wouldn't get a dispatch for the URL and so the dispatch appears to be disabled, something the extension must be able to handle anyway. So the generic nature of the dispatch API helps to keep the code compatible even if the funtionality behind the dispatch might have been changed or removed. Everything else can be dealt with in the code. I also don't agree that the configuration might urge developers to specify a maxversion. There are easy ways to deal with it as the configuration also is a very generic one and so everything can be handled in the code. In the worst case the extension can quit working explicitly if a certain configuration access fails. But I think Frank has mentioned one point where a maxversion *could* make sense: using unpublished APIs. Changing an API used in an extension can make it incompatible and let it crash. This is unavoidable for the extension developer and can't be handled in the extension code. Ciao, Mathias How about the associated slot? Does that change between releases? -- 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] Finding the actual integer value of a numbered paragraph?
ian_mcr123 wrote: Hi, I'm working on an export filter for generating accessible HTML. I identify the html list properties by inspecting the numbering rules of a paragraph (so I find whether it uses Roman numerals etc.) and produce the corresponding HTML. Is it possible to identify the actual integer value of a numbered paragraph? For example, consider the following list. In order to correctly restart the html list after the paragraph I need the integer value of c (ie. 3) in list item L3_2. At the minute I can only identify number by parsing the anchor string of the paragraph. Is there a method of determining the numbering value without parsing the string representation of the number? (perhaps there is a particular property to query?) 1. L0_0 a. L1_0 i. L2_0 a. L3_0 b. L3_1 Paragraph! c.L3_2 ii.L2_1 iii.L2_2 b.L1_1 2.L0_1 I experimented with querying the following properties (without sucess): sal_Int16 numberingStartValue=0; Any aNumberingStartValue; xPropertySet-getPropertyValue(rtl::OUString::createFromAscii(NumberingStartValue)) = aNumberingStartValue; if(aNumberingStartValue = numberingStartValue) { cout numberingStartValue: (int)numberingStartValue endl; } bool isRestart; xPropertySet-getPropertyValue(rtl::OUString::createFromAscii(ParaIsNumberingRestart)) = isRestart; I provided some information here: http://www.oooforum.org/forum/viewtopic.phtml?p=216660#216660 I am of the opinion that you must either parse the text as you have done, or, track the numbering yourself, which only works if you start at the beginning of the document and have one for each numbering 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]
[api-dev] Where did the code snippets go?
Is it me, or did the code snippets page disappear? http://codesnippets.services.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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[api-dev] How to remove a shape from a Draw Page
Michael, This is a very interesting question and I spent an hour or so and was not able to solve the problem. I am copying the dev mailing list to see if there are any clues there: The problem: Assume a draw document with a single shape selected. I want to delete the single shape. The code shown below obtains a reference to the selected shape from the current controller (because it is selected). So, if I have a reference to a shape that is inserted into a draw page, how can I delete it? I tried oShape.Dispose(), which crashed OOo. I tried oShape.getParent().Remove(oShape), which crashed OOo. Original code: Sub Main Dim oShapeName as String Dim oDoc As Object oDoc = ThisComponent oDocCtrl = oDoc.getCurrentController() ' See what is currently selected. oSelection = oDocCtrl.getSelection() If IsEmpty( oSelection ) Then MsgBox( Zum Löschen muss eine Grafik makiert sein ) Exit Sub EndIf If oSelection.getCount() 1 Then MsgBox( Bitte nur eine Grafik zum löschen auswählen ) Exit Sub EndIf oOrigShape = oSelection.getByIndex( 0 ) oShapeName = oOrigShape.getName() print oShapeName REM The Delete Function doesn't work 'oDoc.Remove(oOrigShape) End Sub Nice to hear from you again I am overly busy (nothing new there), but I will take a quick look. Michael Simader wrote: Hi Andrew! How are you? Hope you are find. I think you know me, because you helped me with my macro for inserting a costum shape. It is working great and i updated the macro with a database and i am so proud of it. But now to the problem: If i insert a graphic in the draw document i make a entry in my database, but the problem is, if i delete a shape, i cant remove the database row. So i wrote a macro, where i can select a single shape and get the name of the shape (for deleting the database row), but the problem is, i can't remove the shape from the document. Do you know the methode for removing graphics? Remove a graphic from a Draw document. Did you know that I cover this in my published book? Did you know that the Draw and Impress chapter are available as a free download from the publisher? here is the macro which i want to use for deleting: Sub Main Dim oShapeName as String Dim oDoc As Object oDoc = ThisComponent oDocCtrl = oDoc.getCurrentController() ' See what is currently selected. oSelection = oDocCtrl.getSelection() If IsEmpty( oSelection ) Then MsgBox( Zum Löschen muss eine Grafik makiert sein ) Exit Sub EndIf If oSelection.getCount() 1 Then MsgBox( Bitte nur eine Grafik zum löschen auswählen ) Exit Sub EndIf oOrigShape = oSelection.getByIndex( 0 ) oShapeName = oOrigShape.getName() print oShapeName REM The Delete Function doesn't work oDoc.Remove(oOrigShape) End Sub Yeah, I do not expect you to be able to remove a shape this way. best regards! Your Michael _ Sie möchten Teil der Evolution der Kommunikation werden? http://www.communicationevolved.com/de-at/ -- 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] Where did the code snippets go?
I am writing a new chapter for the OOo Authors site (Macro documentation) and I am documenting places to find macros (amongst other things). I assume, therefore, that I can probably include this in the list. Juergen Schmidt wrote: same for me, we have to wait on a answer from Tom Schindl who maintain the page. Juergen Christian Junker wrote: huch, cannot access it either. 2007/4/3, Andrew Douglas Pitonyak [EMAIL PROTECTED]: Is it me, or did the code snippets page disappear? http://codesnippets.services.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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] How to remove a shape from a Draw Page
Frank Schönheit - Sun Microsystems Germany wrote: Hi Andrew, not having an answer to your question, but ... Assume a draw document with a single shape selected. I want to delete the single shape. The code shown below obtains a reference to the selected shape from the current controller (because it is selected). So, if I have a reference to a shape that is inserted into a draw page, how can I delete it? I tried oShape.Dispose(), which crashed OOo. I tried oShape.getParent().Remove(oShape), which crashed OOo. ... for both of the crashes I would like to see issues in IssueZilla, if possible :) Ciao Frank No Problem. I will enter an issue for both. http://www.openoffice.org/issues/show_bug.cgi?id=76084 I will also assume that this is how I should remove a graphic. -- 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] A link to explain extensions to my Mother please
I am writing a section for OOo documentation for publication that describes OOo Extensions (as in, what are they, how to import, and how to activate). The target audience is interested in creating macros using the macro recorder; and I have a lot of text regarding that complete with pictures. I spent a couple of hours following links and such, but I am still a bit confused. A link to a simple extension that is packaged and ready for activation would be great, preferably with a little readme that says to install this extension, do . If you care, this is what I have so far. An extension is a package that can be installed into OpenOffice.org to add new functionality. An extension, which can be written in almost any programming language, may be very sophisticated or simple. Extensions can be grouped into types: * Calc Add-Ins provide new functionality for Calc, including new functions that act like normal built in functions. * New components and functionality, which normally include some level of UI integration such as new menus or toolbars. * Data pilots, which can be used directly in Calc. * Chart Add-Ins with new chart types. * Linguistic components such as spell checkers. * Document templates and images. Although individual extensions may be found in different places, there is an extension repository here: http://wiki.services.openoffice.org/wiki/Extensions_repository ?? How to import and activate 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] A link to explain extensions to my Mother please
THANKS Juergen, this does help! I really appreciate it. Juergen Schmidt wrote: Hi Andrew, Andrew Douglas Pitonyak wrote: I am writing a section for OOo documentation for publication that describes OOo Extensions (as in, what are they, how to import, and how to activate). The target audience is interested in creating macros using the macro recorder; and I have a lot of text regarding that complete with pictures. I spent a couple of hours following links and such, but I am still a bit confused. A link to a simple extension that is packaged and ready for activation would be great, preferably with a little readme that says to install this extension, do . SNIP Tools - Extension Manager - select My Extensions - Add... After the installation you can select an extension and can simply enable or disable it via the Extensions Manager dialog. Hope this helps a little bit Juergen -- 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] strange value of (ItemEvent).Selected
As a signed value, this would be -1, which might mean that nothing was selected... just a guess. Mikael De Bie wrote: Hi, Using an ItemListener, I wanted to know if the action that triggered the listener was a selection or anything else. I don't find another way that to find the value of oEvt.Selected returned when it's not a selection and to verify that value. The value returned is 65535. All is working fine now, but I wonder why THAT value ? Does someone know something about that ? Here's the code of the CspListBoxListener::itemStateChanged method : --- void CspListBoxListener::itemStateChanged( const awt::ItemEvent oEvt ) throw ( RuntimeException ) { //For an unknown reason, 65535 seems to be the value for a deselection if(oEvt.Selected != 65535){ getDialog()-getAddonImpl()-setSelectedCsp(oEvt.Selected); ((SolverDialog*)getDialog())-updateButtonsState(oEvt.Selected); } } Thanks, Mikael - 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] strange value of (ItemEvent).Selected
Is this a 64 bit version, or the standard build? Stephan Bergmann wrote: Mikael De Bie wrote: On Mon, 2007-04-09 at 22:39 -0400, Andrew Douglas Pitonyak wrote: As a signed value, this would be -1, which might mean that nothing was selected... That's what I've guessed too, but the value I get is always 65535. That's why I'm wondering about that... if someone knows another way to know if the action listened is a selection or anything else, let me know... This smells like a bug where some internal C/C++ unsigned short 65535 (corresponding to signed short -1, presumably a special internal value representing nothing selected) is converted into a UNO long in a wrong way. You should file an issue. -Stephan cheers Mikael Mikael De Bie wrote: Hi, Using an ItemListener, I want to know if the action that triggers the listener is a selection or anything else. I don't find another way that to find the value of oEvt.Selected returned when it's not a selection and to verify that value. The value returned is 65535. All is working fine now, but I wonder why THAT value ? Does someone know something about that ? Here's the code of the CspListBoxListener::itemStateChanged method : --- void CspListBoxListener::itemStateChanged( const awt::ItemEvent oEvt ) throw ( RuntimeException ) { //For an unknown reason, 65535 seems to be the value for a deselection if(oEvt.Selected != 65535){ getDialog()-getAddonImpl()-setSelectedCsp(oEvt.Selected); ((SolverDialog*)getDialog())-updateButtonsState(oEvt.Selected); } } Thanks, Mikael - 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] Replaceing selected text with Basic Macro
Mathias Röllig wrote: Am 17.04.2007 11:45 schrieb Johnny Andersson: Is this what always happens or did I do something wrong? I think no (twice). I filed a issue: http://api.openoffice.org/issues/show_bug.cgi?id=76449 Greetings MRoe I replied to the issue, but I would have said that it was not a bug. I provided code to demonstrate what is really happening here. It may be a bug, but it has been this way since version 1.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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] PageBreak in XTextTable
Michael Jeier wrote: I have a long XTextTable in a writer document. How can I get the number of the row, where a pagebreak occurs? Thanks for your help. Regards, Michael I assume that you need to use the view cursor to count the lines. Ugly, I know, but I can think of no other way. -- 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] Question reg. Sound programming in Basic
Cor Nouws wrote: Hi, I've functions in which quite often properties for controls are set. Thus I could do A) n times oCtrl = oDlgDoc.getControl(name) oCtrl.setSomething or B) n times SetMyControlProp (name) which calls Sub SetMyControlProp (sN$) oCtrl = oDlgDoc.getControl(name) oCtrl.setSomething End Sub B) looks cleaner. However, I've no idea if A or B is faster of better reg. memory usage. Any ideas? Thanks, Cor If I want to know, I place a loop around and count the system ticks to perform the action a few thousand times. If execution time is sufficient, don't worry about it. If it is a problem, consider storing a reference to the control in a global variable and then access them directly. -- 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] Calc Basic Insert Table from text file
Volker Lenhardt wrote: How can I insert a sheet table from a text file (UTF-8) in Calc using Basic? I only find the dispatcher with uno:insert, but what is the syntax? I don't get any further than to get the dialog to insert a table, but I want to use an existing URL directly. Isn't there a way in the API? OOo 2.1 (Windows XP), OOo 2.2 (SuSE Linux 10.1) Regards, Volker Although I will not demonstrate how to insert the file as a sheet, I can at least point you to code that will read it. Look at AndrewBase.odt. I discuss CSV files. The macro named ReadFixedWidthFile(), creates a CSV file and then reads it into a Calc document. You might find something of use... -- 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] Calc Basic Insert Table from text file
Volker Lenhardt wrote: Andrew Douglas Pitonyak schrieb: Look at AndrewBase.odt. I discuss CSV files. The macro named ReadFixedWidthFile(), creates a CSV file and then reads it into a Calc document. You might find something of use... Thank you, Andrew, it helps me to open the file in question. You write to take 65535 for UTF-8 in the options, but I don't succeed. With e.g. 0 or 850 I get the file, but with the wrong encoding, of course. I cannot find a list of valid code numbers, and I don't feel like trying 65635 different settings ;-) Can you tell me? Regards, Volker When I can not find the value, you can import it by hand and then inspect the values that are used. I have a macro to do this in a section titled something like I still can not import my csv file, what do I do now (but a shorter title). I think, however, that Bernard has a good solution for you (a solution I did not know until I read it... 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Calc Basic Insert Table from text file
Volker Lenhardt wrote: and got the GUI dialog to insert a sheet. Understandable, as I have no path mentioned. What is the syntax for doing so? When I looked for an API method I only got to insertNewByName([in] string aName, [in] short nPosition) There is no means whatever to name a URL. You are correct. This routine inserts a new blank sheet with the given name at the specified position. I will take a quick look to see if I can find a way WITHOUT using a dispatch. Can you help me to the spot? Regards, Volker - 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] Calc Basic Insert Table from text file
REM * BASIC * Option Explicit Sub Main Dim oSheet oSheet = ThisComponent.getSheets().getByIndex(0) oSheet.link(file:andrew0/home/andy/foo.csv, _ Sheet1, _ Text - txt - csv (StarCalc), _ FIX,34,0,1,0/3/8/2/19/10, _ com.sun.star.sheet.SheetLinkMode.NORMAL) 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Calc Basic Insert Table from text file
Turns out I had an example in my book that snows how to link. Andrew Douglas Pitonyak wrote: REM * BASIC * Option Explicit Sub Main Dim oSheet oSheet = ThisComponent.getSheets().getByIndex(0) oSheet.link(file:andrew0/home/andy/foo.csv, _ Sheet1, _ Text - txt - csv (StarCalc), _ FIX,34,0,1,0/3/8/2/19/10, _ com.sun.star.sheet.SheetLinkMode.NORMAL) 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Calc Basic Insert Table from text file
Volker Lenhardt wrote: Andrew Douglas Pitonyak schrieb: Turns out I had an example in my book that snows how to link. Andrew Douglas Pitonyak wrote: REM * BASIC * Option Explicit Sub Main Dim oSheet oSheet = ThisComponent.getSheets().getByIndex(0) oSheet.link(file:andrew0/home/andy/foo.csv, _ Sheet1, _ Text - txt - csv (StarCalc), _ FIX,34,0,1,0/3/8/2/19/10, _ com.sun.star.sheet.SheetLinkMode.NORMAL) End Sub Thank you very much, Andrew, it works, though I think the API is slightly cloudy in this respect. :-( I understand that oSheet.link returns a Sheetlink, but it doesn't, when I initialize oSheet by oSheet = oDoc.getSheets().insertNewByName(Voodoo, 0) I have to put it in 2 lines: oDoc.getSheets().insertNewByName(Voodoo, 0) oSheet = oDoc.getSheets().getByName(Voodoo) This is bewildering behavior imho. It returns nothing! http://api.openoffice.org/docs/common/ref/com/sun/star/sheet/XSpreadsheets.html#insertNewByName -- 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] Some Calc Java Macro Issues:
I believe that I have code (Basic) and Calc as a simple database from my web site and now available from the documentation project in the Calc section. As for speed, can you set all the data at one time (or in large groups) using setData or setDataArray? Denis Camargo wrote: Hi. I really need help in a few issues: 1) how can I turn autofilters on in a spreadsheet via java macro? I found that the service DatabaseRange has a property Autofilter, that should be set to true to activate the autofilters. How do I access this property/service? In the API-DEV, theres an old thread, but it did not get me anywhere, the guy was even invited to share his solution as a code snipped, but never did so. (I will =) The OOBasic macro generated by the macro recorder below activates the autofilters, but I was unable to reproduce it using Java: REM * BASIC * Sub Main End Sub sub filters rem -- rem define variables dim document as object dim dispatcher as object rem -- rem get access to the document document = ThisComponent.CurrentController.Frame dispatcher = createUnoService(com.sun.star.frame.DispatchHelper) rem -- dispatcher.executeDispatch(document, .uno:DataFilterAutoFilter, , 0, Array()) end sub 2) I am having a terrible delay in writing the data on the spreadsheet. My macro has to write around (20-30k rows * 9 cols) of information (shading some blocks of rows with related info), and takes around 2 hours to do so. I can't put a sample of the code here right now, but basically i loop through the items, with a nested loop for each row of data for that item, finishing with the shading, like: for( Pack p : packages) { lastRow = rowCount; rowCount = 0; for( Row r : p) { xSpreadsheet.getCell(x, y).setFormula( r.getData1() ); ... xSpreadsheet.getCell(x, y).setFormula(r.getData9() ); rowCount++; } range = xSpreadsheet.getCellRange( rows from lastRow to rowCount, cols 1 to 9) range.shade( isShade() ); } The code above doesn't work I know that. The real program works, it just is taking too long to finish. Is there a way to speedwrite the data? All the data to write to the spreadsheet is available before I begin to write, so if there is a way to write to big chunks of cells at once, that is not a problem. My program works fine, its just it needs a huge optimization. I will upload some real code once I get to a machine with a working USB port. 3 - On the same massive cell writing subject, how can I access the menu command Insert - Spreadsheet from file... via macro? Because I already created a standalone program that writes a tab-separated text file with the data, and then I manually load the file. I lose all the formatting the old macro did, but the whole 30k rows process goes from 2 hours to less than 1 minute. Maybe this is an alternative to problem 2. Thank you so much for reading all that up to here. Hope someone can shed me some light. - 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] 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]
[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] 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]
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
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] 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] 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] 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] 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] 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] 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] 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]