Re: [api-dev] Populating a Calc document via DDE
Hi Davide, On Tue, Jul 26, 2005 at 17:40:39 +0200, Davide Dozza wrote: > >>We've a SAS application which populates an Excel document using DDE. > > > > > > How is that achieved on the Excel side? > > Is it activate from the server side? I figured out it's a push procedure > toward excel not a pull from SAS. Ah, then it's the other way around than I thought, so my previous mail wasn't of real help.. you're using Excel as a DDE server, OpenOffice.org doesn't serve DDE. > Anyway, here is a piece of code: > > submit > filename cmds dde 'Excel|system'; > data _null_ ; > file cmds; > select = '[select("' || "&rows.1&cols.1:&rows.&nrows1&cols.&ncols" > || '")]'; > put select ; > put "[column.width(,,,3)]"; > put select ; > put "[app.activate()]" ; > run ; > endsubmit Yes, the SYSTEM topic in "filename cmds dde 'Excel|system';" lets you execute commands in Excel. In OOo you'd have to use UNO to connect to the application and use the API to push your values. Since you're under Windows you might be interested in OOo's Automation capabilities, see http://udk.openoffice.org/common/man/tutorial/office_automation.html and the example of http://api.openoffice.org/docs/DevelopersGuide/ProfUNO/ProfUNO.htm#1+4+4+Automation+Bridge is almost what you need.. There is also an OOoForum article http://www.oooforum.org/forum/viewtopic.phtml?t=9815 that provides some background and gives examples in various programming languages. Eike -- OOo/SO Calc core developer. Number formatter bedevilled I18N transpositionizer. GnuPG key 0x293C05FD: 997A 4C60 CE41 0149 0DB3 9E96 2F1A D073 293C 05FD - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[api-dev] C++ - Reference<>
Hi, I have a question about UNO Reference<> in C++. What I would like to do is the following : I want to connect to a listening office, and then have an object which keeps a reference to the connection. That way, I can open a connection with the constructor or a function of the object, and call functions to "talk" with the office. Also, I do not want to declare the #include related to the interfaces in my (eg : #include ) header file. That way, when using the object in a .cpp file, for example in a main.cpp, I do not need to include the headers in the compile line. So, what I have done looks like that : file.hxx // Trick to avoid the #includes of OpenOffice in order to use XInterface and // Reference< >. namespace com { namespace sun { namespace star { namespace uno { class XInterface; template< class interface_type > class Reference; } } } } using namespace com::sun::star::uno; class MyClass { public: connect(); set_text(); private : // OK XInterface* rInstance2; // Not OK because needs to be a pointer or a reference. Reference< XInterface > rInstance; }; file.cxx connect() { ... rInstance = rResolver->resolve( OUString::createFromAscii( "uno:socket,host=localhost,port=2083;urp;StarOffice.ServiceManager" ) ); ... } set_text() { ... Reference< XDesktop > xdesktop( rInstance, UNO_QUERY ); ... } But, for now, I am not able to declare "Reference< XInterface > rInstance". What would be the right way to do things ? To make rInstance a reference (&) to a Reference< XInterface > ? Reference< XInterface > & rInstance; To connect to the listening office in each method wanting to access to objects (which would be long, I suppose) ? Use a global variable in the cxx file (bad style programming) ? Thanks, Cheers, Pierre-Andre -- StarXpert - www.starxpert.fr e-mail : [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[api-dev] Browsing the source code
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]
Re: [api-dev] C++ - Reference<>
Hello Pierre-André, > using namespace com::sun::star::uno; side-note: using directives are bad in header files. Use fully qualified names. > class MyClass > { > > public: > connect(); > set_text(); > > private : > // OK > XInterface* rInstance2; > > // Not OK because needs to be a pointer or a reference. > Reference< XInterface > rInstance; > }; > This does not work. I would recommend that you "pimpl" your class, hiding implementation details in a separate class, e.g. hpp file: // no need not to include OOo header files #include ... class MyClass { ... private: class MyClassImpl; ::std::auto_ptr const m_pImpl; }; ... cpp file: // using OOo headers, definitions of class MyClass::MyClassImpl ... class MyClass ... But if you only have to hold a single interface member, it is probably shorter to just use the plain "XInterface *", manually managing lifetime via acquire() / release(). HTH, -Daniel - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] C++ - Reference<>
Le Mercredi 27 Juillet 2005 15:22, Daniel Boelzle a écrit : > Hello Pierre-André, Hi Daniel, > > using namespace com::sun::star::uno; > > side-note: using directives are bad in header files. Use fully > qualified names. :-) Thanks, I will correct that. > > class MyClass > > { > > > > public: > > connect(); > > set_text(); > > > > private : > > // OK > > XInterface* rInstance2; > > > > // Not OK because needs to be a pointer or a reference. > > Reference< XInterface > rInstance; > > }; > > This does not work. I would recommend that you "pimpl" your class, > hiding implementation details in a separate class, e.g. > hpp file: > // no need not to include OOo header files > #include > ... > class MyClass > { > private: > class MyClassImpl; > ::std::auto_ptr const m_pImpl; > }; > > cpp file: > // using OOo headers, definitions of > class MyClass::MyClassImpl ... > class MyClass ... Hum, the class I showed you is supposed already to be a class to hide OOo details... > But if you only have to hold a single interface member, it is probably > shorter to just use the plain "XInterface *", manually managing lifetime > via acquire() / release(). From the Dev's Guide : "Acquire and release must be implemented in a thread-safe fashion." Sounds scarry ;-) How would that work ? Would it be ok that way : - hpp file class MyClass { public: connect(); private : XInterface* rInstance; }; - cpp file : MyClass::Myclass { rInstance = new XInterface; *rInstance.acquire(); }; // Can release throw ? Hope it does not ! MyClass::~Myclass { *rInstance.release(); }; void MyClass::connect() { // Would this work ? *rInstance = rServiceManager->createInstanceWithContext( OUString::createFromAscii( "com.sun.star.bridge.UnoUrlResolver" ), rComponentContext ); ... } By the way, it now works using a pointer to the Reference. Reference< XInterface > *rInstance; Thanks for the comments,, Pierre-André -- StarXpert - www.starxpert.fr e-mail : [EMAIL PROTECTED] - 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 <[EMAI
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] Populating a Calc document via DDE
Davide Dozza wrote: Hi all, We've a SAS application which populates an Excel document using DDE. We need to translate such procedure in order to populate a Calc document in the same way. The question is: how much is DDE standard enough in order to reuse the code? Davide The DDE is probably NOT standard. Here is code that I used: Sub ExampleDDE Dim nDDEChannel As Integer Dim s As String REM OOo must have the file open or the channel will not be opened nDDEChannel = DDEInitiate("soffice", "c:\TST.sxc") If nDDEChannel = 0 Then Print "Sorry, failed to open a DDE channel" Else Print "Using channel " & nDDEChannel & " to request cell A1" s = DDERequest(nDDEChannel, "A1") Print "Returned " & s DDETerminate(nDDEChannel) End If End Sub Officially, I think that DDE is no longer supported, but last I heard, this code works in the latest Beta. In 1.1.x, this will cause OOo to crash. -- 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]