[api-dev] XTextRange.getString empty if more than 65000 chars
Hi everybody, As far as my tries have gone, it seems that a TextRange cannot return its string (through getString() ) if its length is higher than a certain limit, which I estimate to be around 65000 characters. Is it documented somehow ? Is there another workaround than enumerating TextPortions to retrieve TextRanges with a finer granularity ? I use OO 2.0.3 (Windows version). Thank you if you can help. Julien Galand - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[api-dev] How to get paragraph from TextRange
Hi to all, 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) I have read in a mail of this list that the TextRange service implements XEnumerationAccess, apparently in the same way as the Text service does. I have tried, and it seems to give some result, but : - XEnumerationAccess on TextRange seems undocumented (at least in the SDK 2.0 I have); will this interface be maintained or published in the future ? - Can I be sure that it is the TextRange service itself that implements XEnumerationAccess, and not only some services including TextRange, such as TextCursor, TextPortion, etc. ? (I have tried on both TextCursor and TextPortion, it works) For instance, is the following navigation in the text model valid : Text -> by XEnumerationAccess, enumerate all Paragraph Paragraph -> by XEnumerationAccess, enumerate all TextPortion TextPortion -> since it includes TextRange, by XEnumerationAccess, enumerate again the (only) paragraph "contained" in the range of the portion etc. ad infinitum ? It seems to work ! Thank you if you have any hint or confirmation of this surprising use of interfaces, Julien Galand - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[api-dev] Listening to TextRange string
Hi everybody, Is there a way to be notified when the content (the string, I mean) of a TextRange is changed ? I feel that the answer is negative, from some mails I've read in this list, but in case there is a miracle... TextRange publishes XPropertySet, which enables registration of a property listener, but there is no such thing as a 'string' property (at least, documented). Thank you if you know a trick on this, Julien Galand - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[api-dev] Listening to TextRange string
Hi everybody, Is there a way to be notified when the content (the string, I mean) of a TextRange is changed ? I feel that the answer is negative, from some mails I've read in this list, but in case there is a miracle... TextRange publishes XPropertySet, which enables registration of a property listener, but there is no such thing as a 'string' property (at least, documented). Thank you if you know a trick on this, Julien Galand - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[api-dev] How to lock a text model
Hi to all, Does someone know a way to lock/unlock the model of a text document, that is, to make it temporarily read-only (the user cannot change its content) ? My purpose is to make sure that when my add-on is currently retrieving the text and manipulating it later, it has not changed in between. Because I assume OO to be fully multithread, it seems theoretically possible to me that the user (or any component other than mine) may modify the text while my add-on thread is working on it. Maybe something to do with the controller ? (XModel.lockControllers disables only screen updates) Best regards, Julien Galand - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] How to lock a text model
OOo is not multithreaded, but it's possible that two threads can work on the same OOo model as it is not locked between API calls. This will change with our new Threading Framework in the future where code executed in any thread can obtain an exclusive lock for a defined span of time. ATM you can't lock a model against changes through its API, but you can prevent it from being modified through UI operations (dispatch calls). Thank you, Mathias, for this clear answer. Could you please tell me more about how to disable modifications of a document through UI, as I don't know exactly where to start for this ? (and there are many ways for a user to modify : menu, keyboard, toolbars...) Julien Galand - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[api-dev] How to assign keyboard shortcut to add-on menu
Hi, I have read an answer by Mathias Bauer mailed on 11/18/2004 that it was not currently possible to assign a keyboard shortcut to an add-on menu line. Is it still impossible with OO 2.0 ? Even if the assignment is dynamic (not persistent), made by some API (typically by XAcceleratorConfiguration.setKeyEvent) and not by a XCU file ? Thank you if you can confirm this (in which case I feel a bit disapointed...). Julien Galand - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[api-dev] Refreshing a modified menu bar
Hi everybody, I have written an add-on which inserts its menu in the "OfficeMenuBar" as a top-level menu. Instead of using a .xcu installed with the add-on package, it creates and inserts its menu dynamically, using the "com.sun.star.configuration" module to modify OO's configuration, at the "/org.openoffice.Office.Addons/AddonUI/OfficeMenuBar" node. I have limited this menu to com.sun.star.text.TextDocument modules. Then the changes made in the configuration are committed through XChangesBatch.commitChanges(). Everything works well, except that the menu bars of the currently opened documents are not refreshed. The new menu will appear only for documents opened afterwards. I have tried XUIConfigurationPersistence.reload() on a ModuleUIConfigurationManager service (itself retrieved by XModuleUIConfigurationManagerSupplier.getUIConfigurationManager("com.sun .star.text.TextDocument")), it doesn't seem to improve the behavior. Does someone know a way to refresh the currently opened menu bars ? Julien Galand - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] How to assign keyboard shortcut to add-on menu
Le 13 oct. 06, à 15:10, Laurent Godard a écrit : *** This message was sent to your KasMail disposable email address: dev@api.openoffice.org *** HI I have read an answer by Mathias Bauer mailed on 11/18/2004 that it was not currently possible to assign a keyboard shortcut to an add-on menu line. Is it still impossible with OO 2.0 ? Even if the assignment is dynamic (not persistent), made by some API (typically by XAcceleratorConfiguration.setKeyEvent) and not by a XCU file ? Thank you if you can confirm this (in which case I feel a bit disapointed...). did you try to add a ~ in your string defining the menu ? Laurent -- Laurent Godard <[EMAIL PROTECTED]> - Ingénierie OpenOffice.org - http://www.indesko.com Nuxeo Enterprise Content Management >> http://www.nuxeo.com - http://www.nuxeo.org Livre "Programmation OpenOffice.org", Eyrolles 2004-2006 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Thank you for your proposal, but I didn't mean "accelerator" (a special letter chosen for each menu line), but a shortcut as a combination of keys (such as Ctrl+F12). Julien - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Refreshing a modified menu bar
Le 13 oct. 06, à 16:54, Carsten Driesner a écrit : Although this is a possible way to implement your add-on it looks a bit strange and has a drawback you should consider. If the user choose to uninstall your add-on all the changes you did programmatically in the configuration won't be removed. The user would see a non-working top-level menu! Therefore I cannot recommend to use this way. I agree; in the case of my add-on, I strongly needed to avoid manual registration of a package. As a "solution" to this drawback, I have chosen to remove the inserted menu (modifying the configuration again) when OO quits (on OnCloseApp event). You can use the layout manager from the frame to destroy and create the menu bar again. The current implementation doesn't listen to changes in the Addon.xcu file. The following Basic code snippet "refreshes" the menu bar. REM * BASIC * Sub Main REM *** Initialize strings sMenubar = "private:resource/menubar/menubar" REM *** Retrieve the desktop service oDesktop = createUnoService("com.sun.star.frame.Desktop") REM *** Retrieve the current frame and layout manager oCurrFrame = oDesktop.getCurrentFrame() oLayoutManager = oCurrFrame.LayoutManager REM *** Destroy and create menu bar to refresh content oLayoutManager.destroyElement( sMenubar ) oLayoutManager.createElement( sMenubar ) End Sub Regards, Carsten I have tried your suggestion. It doesn't seem to work, though all calls seem to be successful. I have only one (writer) document opened. My code is parallel to yours, in C++ : __ Reference curFrame = m_appDesktop->getCurrentFrame(); Reference layoutMgr(GetObjectProperty(curFrame, "LayoutManager"), UNO_QUERY); OUString element = OUString::createFromAscii("private:resource/menubar/menubar"); layoutMgr->destroyElement(element); layoutMgr->createElement(element); __ What may happen ? Julien - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[api-dev] OnCloseApp not dispatched by OO 2.0.1
Hi, I have noticed with an add-on I have written that the global event "OnCloseApp" is not dispatched by OO 2.0.1 (or maybe OO disconnects global event listeners too early when quitting). With the same add-on and OO 2.0.3, this event is correctly received. I have searched in the issue tracker for "OnCloseApp", I haven't found any related issue. Maybe I haven't searched rightly. Is this bug known (if it is one) ? Has it been fixed in OO 2.0.2 or 2.0.3, so that I can warn my customers ? Julien Galand - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Refreshing a modified menu bar
Le 16 oct. 06, à 12:47, Carsten Driesner a écrit : You're right that the configuration data of a package is merged into the Office configuration. The user interface configuration data is processed by a different implementation and is not coupled with the Office configuration. Add-ons use an Office configuration file (Addons.xcu) to supported merging and installation/deinstallation. The Addons.xcu data is read by the user interface configuration implementation and merged into the OOo user interface. If a document window has read the Addons.xcu, it won't detect any changes as it doesn't listen to changes. If you use the user interface configuration API you get automatic update/refresh (just use the Tools-Customize dialog and change the menu or a toolbar). Regards, Carsten Hi Carsten, As remarked in my previous message, I have tried your suggestion to use XLayoutManager. destroyElement/createElement to force the menu bar to refresh itself, without success. As it is true that OO does such a refresh when using the customize dialog, I keep hope that there must be a way...(maybe not feasible by the API). Is it reasonable that I take a look into OO's source files ? Do you know a starting point for me where such an example of a refresh of the menu bar is made ? Thanks anyway for your previous answer, Best regards, Julien - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Refreshing a modified menu bar
Le 16 oct. 06, à 13:38, Carsten Driesner a écrit : I checked my code and it works without any problem. OpenOffice.org internally uses the same mechanism, if you customize the menubar with Tools-Customize. Please check if you use the correct frame to destroy/create the menubar. Hi Carsten, I have checked more thoroughly, and it seems that your sample code (with destroyElement/createElement) does nothing if called too early during the startup phase (even though the document and its frame is visually complete). I have tried to call it later, and it works. Thank you again for this. Although your solution may work in most cases, a crash would leave persistent changes. You should consider to use transient changes on the user interface. The Basic code at the end of this message uses the transient user interface feature to change the menu bar for a frame. No other frame can see the changes and even a crash won't change any file. - Sample code to make transient changes on a frame menu bar (...) I agree perfectly that the persistant change made to the menu bar by my add-on isn't satisfying. I will try your alternative solution (transient modifications) as soon as I can. However, I fear a bit about using so many "unpublished" features, mostly because we will sell our add-on to many customers who will upgrade OO regularly but not necessarily our add-on. Could you please tell me your feedback about the stability of this "underdocumented" API in the future ? (I mean, accessing the layout manager, retrieving the menu bar by its element name, setting the 'Persistent' property, using the element settings, browsing through the menu tree, etc.) Can I be confident about its lifetime ? Thank you anyway for your complete answer. Julien - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Refreshing a modified menu bar
Le 17 oct. 06, à 17:02, Carsten Driesner a écrit : You're right that these APIs are not well documented, only the IDL files have comments. That's one reason why they are currently not published. We want to finalize them for OpenOffice.org 2.2 (a formal process) and after finalization they cannot be changed in the future. As these services/interfaces are more than two years old and no big issues have been reported so far I would be very surprised, if there will be changes during the finalization process. Therefore we want to encourage you to use these services/interfaces to implement your add-on. Thank you for this confirmation. I have tried your alternative solution (using transient changes of the menu bar), and of course it works perfectly. It is far more better than my first implementation (persistent modifications through OO configuration), and as you have just told me, also reliable for the future. Thank you very much ! One last question about it : Mathias Bauer has already answered to me that assigning keyboard shortcuts (such as Ctrl+F12) to add-on menus is presently not possible in OO 2.0. But is it possible to DISPLAY only the shortcut (say, Ctrl+F12) in the menu line, so that it is right-justified on the line ? (Typically in the "transient change of the menu bar" method) (and I implement the shortcut detection itself by a system hook). Note : I have tried to scan the OO menu bar to check what "Label" property it assigns to menu lines with a displayed shortcut, but I always get an empty string. Maybe I made it wrong, but anyway I couldn't get any hint by this. Julien - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[api-dev] Bug in C++ UNO binding of awt::KeyEvent ?
Hi, Maybe this mail isn't appropriate in this mailing list (then tell me). As far as I have understood, there seems to be a bug in the C++ UNO binding of the awt::KeyEvent structure. When using the following code snippet to set keyboard shortcuts programmatically by the API : http://codesnippets.services.openoffice.org/Office/ Office.ManagingKeyboardShortcuts.snip It works well when called from a script (say, automation by jscript) or from Basic (the snippet); then the relevant field is KeyEvent.KeyCode. But when called from C++ (XAcceleratorConfiguration.getKeyEventsByCommand, setKeyEvent, etc.), it seems to be KeyEvent.KeyChar (either on passing or on return) ! Using this fields instead makes the snippet works in C++. Should I report this in some way (file an issue) ? I am not familiar with this. Julien Galand - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Refreshing a modified menu bar
Le 18 oct. 06, à 14:46, Carsten Driesner a écrit : I think you should use the API to set your keyboard shortcut. Just have a look the a the following code snippet how to do it: http://codesnippets.services.openoffice.org/Office/ Office.ManagingKeyboardShortcuts.snip There are many examples on the code snippet page and you should take a look, may be you can find other interesting things. Thanks for this link. I had tried this previously and it didn't work, but I think I have now found the cause (there is apparently a bug in the C++ UNO binding about the awt::KeyEvent structure, for which I have just posted a mail in this mailing list), and I could make it work. But the real question in my previous mail was to display the shortcut in the menu line. The code snippet above doesn't change anything in the menu added by the "transient change" method (I have set the same command URL on the shortcut and the menu line, hoping that OO would associate both automatically). Is there a way to display for example "Ctrl+F12" on the right of a menu line (and right-justified) ? Julien Galand - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Refreshing a modified menu bar
Le 19 oct. 06, à 09:45, Tobias Krais a écrit : you wrote, that you want to sell this solution. Please be aware of this bug when doing this: http://www.openoffice.org/issues/show_bug.cgi?id=66236 Hi Tobias, Thank you. I was not aware of that. Julien - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Bug in C++ UNO binding of awt::KeyEvent ?
Le 19 oct. 06, à 14:00, Stephan Bergmann a écrit : I very much doubt that this is directly a problem of the UNO C++ language binding. com.sun.star.awt.KeyEvent is a UNO struct that has members KeyChar and KeyCode. Maybe you can post the failing C++ code here (if it is not too long) and somebody with awt knowledge can spot the real problem. Hi Stephan, The test code for this bug is simple, and is similar to the Basic code snippet: // Let 'm_serviceMgr' be the service manager interface. // Reference xUICfgSupp(m_serviceMgr->createInstance(OUString:: createFromAscii("com.sun.star.ui.ModuleUIConfigurationManagerSupplier")) , UNO_QUERY_THROW); Reference xUICfgMgr = xUICfgSupp->getUIConfigurationManager(OUString:: createFromAscii("com.sun.star.text.TextDocument")); Reference shortcutMgr(xUICfgMgr->getShortCutManager(), UNO_QUERY_THROW); awt::KeyEvent keyEvent; / /--- - // BUG (of binding ?) : Use KeyEvent.KeyChar, and not KeyEvent.KeyCode !! // // Note: // The same bug appears when retrieving a KeyEvent, such as // XAcceleratorConfiguration.getKeyEventsByCommand(".uno:AddDirect"). // => the returned KeyEvents have KeyChar filled by what should be in KeyCode. / /--- - // keyEvent.KeyChar = awt::Key::F11; keyEvent.Modifiers = awt::KeyModifier::MOD1; // Ctrl+F11 OUString commandURL = OUString::createFromAscii(".uno:AddDirect"); // this command is just as a test try { shortcutMgr->removeKeyEvent(keyEvent); } catch (NoSuchElementException &) {} shortcutMgr->setKeyEvent(keyEvent, commandURL); shortcutMgr->store(); I first suspected a struct alignment problem, but it doesn't seem to be so. I use OO 2.0.3. Julien Galand - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Refreshing a modified menu bar
Le 19 oct. 06, à 14:52, Carsten Driesner a écrit : Julien Galand wrote: Thanks for this link. I had tried this previously and it didn't work, but I think I have now found the cause (there is apparently a bug in the C++ UNO binding about the awt::KeyEvent structure, for which I have just posted a mail in this mailing list), and I could make it work. But the real question in my previous mail was to display the shortcut in the menu line. The code snippet above doesn't change anything in the menu added by the "transient change" method (I have set the same command URL on the shortcut and the menu line, hoping that OO would associate both automatically). Is there a way to display for example "Ctrl+F12" on the right of a menu line (and right-justified) ? Hi Julien, OpenOffice.org should display all associated keyboard shortcuts automatically in the menu. If it doesn't work for your example, then I guess that it's a bug. So could you write me a bug for this issue and add a small example to reproduce it? Hi Carsten, I have spent several hours to boil down the phenomenon. From my tests, I have concluded that this "display connection" of the shortcut with its menu line doesn't work when the menu line is in a submenu (i.e. not a line in a menu of the menu bar, but in a submenu of a menu). When it is simply a menu line of a menu of the menu bar, it works. It looks like a bug. I use OO 2.0.3. With regards to a sample code, I have got one, but only in JScript, as I am much more used to it than Basic. Copy the sample below in a text file, say "Insert_new_menu_and_shortcut.js". I launch the script in Windows, with a simple command line (OO should be running) : cscript "Insert_new_menu_and_shortcut.js" I hope JScript won't be a burden for you. If it were, tell me and I will try to translate it in OO Basic with my little knowledge of it. Here is the sample : (you can try both cases, with a simple menu line, or with a submenu, by assigning the 3rd parameter of 'InsertMenu') __ var ooServMgr = WScript.CreateObject("com.sun.star.ServiceManager"); var mycommand = "macro:///Standard.Module1.Test()"; // Set the 3rd parameter to 'true' to insert a submenu in the "File" menu. // This submenu has only one line. // Or 'false' to insert only the menu line in the "File" menu. // InsertMenu(ooServMgr, mycommand, true); InsertShortcut(ooServMgr, mycommand); function InsertMenu(ooServMgr, myCommand, bWithSubmenu) { var ooDesktop = ooServMgr.createInstance("com.sun.star.frame.Desktop"); var curFrame = ooDesktop.getCurrentFrame(); var layoutMgr = curFrame.LayoutManager; var menuElementName = "private:resource/menubar/menubar"; var menuBar = layoutMgr.getElement(menuElementName); var menuBarSettings = menuBar.getSettings(true); menuBar.Persistent = false; // Find the "File" popup menu. // var fileMenuIndex = FindCommand(".uno:PickList", menuBarSettings); if (fileMenuIndex >= 0) { var popupMenuItem = menuBarSettings.getByIndex(fileMenuIndex).toArray(); var popupMenu = GetProperty("ItemDescriptorContainer", popupMenuItem); //if (FindCommand(myCommand, popupMenu)==-1) { var menuItem; menuItem = CreateMenuItem(ooServMgr, myCommand, "Test shortcut", null); var menuItemPassed = ooServMgr.Bridge_GetValueObject(); menuItemPassed.Set("[]com.sun.star.beans.PropertyValue", menuItem); if (bWithSubmenu) { var submenu; submenu = menuBarSettings.createInstanceWithContext(ooServMgr.DefaultContext); submenu.insertByIndex(0, menuItemPassed); menuItem = CreateMenuItem(ooServMgr, "", "Test shortcut submenu", submenu); menuItemPassed.Set("[]com.sun.star.beans.PropertyValue", menuItem); } popupMenu.insertByIndex(popupMenu.getCount(), menuItemPassed); } } menuBar.setSettings(menuBarSettings); } function FindCommand(command, menuBarSettings) { for (var i=0; i if (popupMenu[j].Name=="CommandURL" && popupMenu[j].Value==command) return i; } } return -1; } function GetProperty(propertyName, properties) { for (var i = 0; i menuI
Re: [api-dev] Bug in C++ UNO binding of awt::KeyEvent ?
Le 20 oct. 06, à 10:54, Mathias Bauer a écrit : Julien Galand wrote: // BUG (of binding ?) : Use KeyEvent.KeyChar, and not KeyEvent.KeyCode !! // // Note: // The same bug appears when retrieving a KeyEvent, such as // XAcceleratorConfiguration.getKeyEventsByCommand(".uno:AddDirect"). // => the returned KeyEvents have KeyChar filled by what should be in KeyCode. // keyEvent.KeyChar = awt::Key::F11; keyEvent.Modifiers = awt::KeyModifier::MOD1; // Ctrl+F11 OUString commandURL = OUString::createFromAscii(".uno:AddDirect"); // this command is just as a test try { shortcutMgr->removeKeyEvent(keyEvent); } catch (NoSuchElementException &) {} shortcutMgr->setKeyEvent(keyEvent, commandURL); shortcutMgr->store(); I recommend to do the following: Make sure that you have the default configuration and use "getKeyEventsByCommand" to see what you get. It should yield the same result as in Basic. Hi Mathias, I have followed your advice. Doing so enabled me to investigate further, and I have concluded that there is definitely an alignment weakness in the UNO C++ headers. The point is that I compile my add-on with alignment 2. I thought there would be no problem since all UNO structures are wrapped with : #pragma pack(8) struct { ... } #pragma pack() But there is a subtlety. Nothing is better than an example, the one I have coped with : #pragma pack(push, 8) struct EventObject { Reference Source; }; struct myEventObject { void *Source; }; #pragma pack(pop) ==> sizeof(EventObject)==4 && sizeof(myEventObject)==4 #pragma pack(push, 8) struct myInputEvent: public myEventObject { short Modifiers; }; struct InputEvent: public EventObject { short Modifiers; }; #pragma pack(pop) The size of myInputEvent is 8 (at least with Visual C++), because the 'myEventObject' type has requested to be aligned on 8-bytes boundary, and therefore its 'Source' field must be aligned on 4-bytes boundary. The compiler adjusts the size of the structure so that an array of myInputEvent makes the Source field fall on 4-bytes boundaries. But if the default alignment compiler option is set to 2, the size of InputEvent is 6, even though EventObject and my EventObject look equivalent at first sight. Why ? Because the Reference<> template is itself a structure, not a basic type, and NOT wrapped with #pragma pack(8). So the compiler doesn't bother to keep it aligned on 8-bytes or even 4-bytes boundary. Consequence : The awt::KeyEvent structure doesn't match the one of UNO in a C++ component compiled with such an option. As a conclusion : - Either compile a C++ UNO component with the alignment compiler option set to 8 (or at least all SDK/UNO headers). - Or the Reference<> template structure definition should be wrapped with #pragma align(8). But the latter option is a fix in the SDK. Should I report this to someone ? Or should I forward this mail to another dedicated list ? Julien Galand - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[api-dev] Registering Protocol Handler dynamically
Hi everybody, I would like to register a protocol handler of my add-on dynamically, that is, without the - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[api-dev] Registering Protocol Handler dynamically
Hi everybody, I would like to register a protocol handler of my add-on dynamically, that is, without modifying the "/org.openoffice.Office.ProtocolHandler/HandlerSet" node of the OO user configuration file (whether by a .xcu or by using the configuration API). This way has some drawbacks (hinders the speed of OO's startup, and leaves an entry in this file when the add-on is uninstalled). Is it possible ? This entry seems mandatory in order for the protocol handler to be called. I admit I haven't explored the "dispatch interception" mechanism, which maybe could give me an alternative. Julien Galand - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Refreshing a modified menu bar
Carsten Driesner a écrit : Julien Galand wrote: Hi Carsten, I have spent several hours to boil down the phenomenon. From my tests, I have concluded that this "display connection" of the shortcut with its menu line doesn't work when the menu line is in a submenu (i.e. not a line in a menu of the menu bar, but in a submenu of a menu). When it is simply a menu line of a menu of the menu bar, it works. It looks like a bug. I use OO 2.0.3. Hi Julien, If you are right then it would be a bug. It's a little bit strange as I can see keyboard shortcuts in sub menus using OOo 2.0.4. Writer menu: Table - Insert - Table...Strg+F12 Tools - Update - Fields F9 Insert - Fields - Other... Strg+F2 The OpenOffice.org menu implementation uses the accelerator configuration to show shortcuts assigned to functions. JScript shouldn't be a problem. I will check you example on Monday and may be I am able to shed light on this issue. Hi Carsten, I agree about this "strangeness", as I have also checked whether there were any submenu in OO with displayed key shortcuts. Have you had some time to check my sample script ? I hesitate about what to do (because I have to find a solution for my add-on that will be released soon). If it is a bug, then I give up all investigation. If it is not, then maybe I haven't found the right way to do it. Another possibility for me is to check the OO's source files, to see how it does it. But I don't feel it's the easiest way for me (I have never dove into OO's source code) ! I will take a quick look tomorrow. Regards, Julien Galand - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Refreshing a modified menu bar
Le 27 oct. 06, à 08:12, Carsten Driesner a écrit : I wasn't able to run your example as I need a dedicated machine for testing. Currently I only have remote access (with and therefore cannot use a normal Office installation. That's why the script cannot create the Office service manager. I hope that I can check your script today, using a dedicated machine. Hi Carsten, I was a bit afraid that sending you a JScript sample would not facilitate your job. So I have tried my best translating it into OOBasic (using frequent copy/paste from the samples you've sent to me !), and checked it. Here is the result below. Just try to execute the 'Main' sub first with 'false' as the 2nd parameter of InsertMenu. Then with 'true'. In the 1st case, a menu line is appended to the writer "file" menu, with a Ctrl+F11 key shortcut. It is displayed, and works when one strokes Ctrl+F11 (a msgbox is then showed). In the 2nd case, the same line is put into a submenu, itself appended to the "file" menu. The key shortcut is still assigned, works, but is not displayed. I hope you will see the same phenomenon. Regards, Julien Galand ___ Sub Main sMyCommand = "macro:///Standard.Module1.Test()" ' Set the 2nd parameter to 'true' to create a submenu in the "file" menu. ' Set it to 'false' to create only a menu line in the "file" menu. ' ' In both cases, the final menu line is assigned a key shortcut (here Ctrl+F11). ' InsertMenu(sMyCommand, false) InsertShortcut(sMyCommand) End Sub Sub InsertMenu(sCommand as String, bWithSubmenu as boolean) sMenuBar = "private:resource/menubar/menubar" sMyPopupMenuCmdId = ".uno:PickList" REM *** Retrieve the current frame of my model oModel = ThisComponent if not isNull( oModel ) then oFrame = oModel.getCurrentController().getFrame() oLayoutManager = oFrame.LayoutManager() oMenuBar = oLayoutManager.getElement( sMenuBar ) oMenuBarSettings = oMenuBar.getSettings( true ) oMenuBar.Persistent = false fileMenuIndex = FindCommand( sMyPopupMenuCmdId, oMenuBarSettings ) if fileMenuIndex >= 0 then oPopupMenuItem() = oMenuBarSettings.getByIndex(fileMenuIndex) oPopupMenu = GetProperty( "ItemDescriptorContainer", oPopupMenuItem() ) if not isNull( oPopupMenu ) then 'if FindCommand( sCommand, oPopupMenu ) = -1 then oMenuItem = CreateMenuItem( sCommand, "Standard.Module1.Test", null ) if bWithSubmenu then oSubmenu = oMenuBarSettings.createInstanceWithContext(GetDefaultContext()) oSubmenu.insertByIndex(0, oMenuItem) oMenuItem = CreateMenuItem( "", "Standard.Module1.Test submenu", oSubmenu) endif nCount = oPopupMenu.getCount() oPopupMenu.insertByIndex( nCount, oMenuItem ) 'endif endif else msgbox "No file menu found!" endif oMenuBar.setSettings( oMenuBarSettings ) endif End Sub Function FindCommand( Command as String, oPopupMenu as Object ) as Integer nCount = oPopupMenu.getCount()-1 for i = 0 to nCount oMenuItem() = oPopupMenu.getByIndex(i) nPropertyCount = ubound(oMenuItem()) for j = 0 to nPropertyCount if oMenuItem(j).Name = "CommandURL" then if oMenuItem(j).Value = Command then FindCommand = j exit function endif endif next j next i FindCommand = -1 End Function Function GetProperty( PropertyName as String, properties() as Variant ) as Variant for j = lbound( properties() ) to ubound( properties() ) oPropertyValue = properties(j) if oPropertyValue.Name = PropertyName then GetProperty = oPropertyValue.Value exit function endif next j GetProperty = null end function Function CreateMenuItem( Command as String, Label as String, oSubmenu as Variant ) as Variant Dim aMenuItem(2) as new com.sun.star.beans.PropertyValue aMenuItem(0).Name = "CommandURL" aMenuItem(0).Value = Command aMenuItem(1).Name = "Label" aMenuItem(1).Value = Label aMenuItem(2).Name = "Type" aMenuItem(2).Value = 0 if not isNull( oSubmenu ) then redim preserve aMenuItem(3) aMenuItem(3).Name = "ItemDescriptorContainer" aMenuItem(3).Value = oSubmenu endif CreateMenuItem = aMenuItem() End Function Sub InsertShortcut(sCommand as String) oModuleCfgMgrSupplier = createUnoService("com.sun.star.ui.ModuleUIConfigurationManagerSupplier"
[api-dev] Enable toolbar items if dynamic protocol handler
Hi to all, My add-on has a toolbar created by a .xcu file, with the right protocol handler declared (as a node "org.openoffice.Office.ProtocolHandler/HandlerSet" of the configuration file). But there is no component registration in the package; in particular no registration of the implementation of the service of the protocol handler. Instead, the service of the protocol handler is registered dynamically by the executable component of my add-on, therefore necessarily LATER than OO's reading of the .xcu file. => The toolbar items are shown disabled, probably because the protocol handler service couldn't be instanciated at the time the toolbar was created. Is there a way to ask OO to re-scan the toolbar items to bind them to the protocol handler, which will likely make them enabled ? Thank you if you have some hint... Julien Galand - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Enable toolbar items if dynamic protocol handler
Le 2 nov. 06, à 18:50, Tabish F. Mufti a écrit : So what you are trying to do is that you have your own wrapper app which creates a toolbar at run time and the component is never deployed into openoffice ? Yes, it may be a good description. It is rather an add-on (loaded into OO's process) than an external app. This component is not registered by a package, but dynamically. Only the toolbar and the protocol handler are declared in the user configuration (typically by a .xcu file deployed into OO). OO doesn't know where the protocol handler is implemented by reading only the configuration. It has this information (but later) when the component is dynamically registered. Julien Galand - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Enable toolbar items if dynamic protocol handler
Le 3 nov. 06, à 13:58, Tabish F. Mufti a écrit : Would you please like to share with me your solution after you are done. I would like to have your files and and how you are running them etc. only if you are working in java. I actually tried searching about doing such a thing and I thought its not possible in openoffice.org so later I had to resort to just installing my component into openoffice.org using the unopkg. My solution is specific to Windows, and my component is written in C++. Being a Windows executable, it is able (by some system hook) to inject itself into OO's process, and then to register itself dynamically to OO. Does this context still interest you ? Julien Galand - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Refreshing a modified menu bar
Le 2 nov. 06, à 10:31, Carsten Driesner a écrit : I was able to reproduce your problem and found the root cause. Could you please write me an issue for this problem. The problem is related to the fact that the popup menu doesn't need to retrieve labels, therefore an internal flag is not set. The shortcut retrieval is bound to this flag, which is obviously a bug. Thanks for your script and help to track down this issue. Hi Carsten, Thank you for your investigation. As it is the first time I write an issue, please check the following: http://www.openoffice.org/issues/show_bug.cgi?id=71154 I guess there is no simple workaround, otherwise you would have mentioned it... Regards, Julien Galand - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Refreshing a modified menu bar
Le 3 nov. 06, à 15:55, Carsten Driesner a écrit : There is a "simple" workaround, but I am not sure you can accept the drawback. You have to make sure that at least one entry in your sub-menu has no label set. OpenOffice.org tries to find a label using the command URL. The *Commands.xcu files in installation>/share/registry/data/org/openoffice/Office/UI define the labels language dependent for every UI command. To ensure that the workaround works: - You have to add a built-in UI command to your sub-menu (e.g. ".uno:Quit). OR - You have to add a GenericCommands.xcu file to your add-on, which defines the label for your command. Leave the label of your menu item empty. I am not sure that this is acceptable for you? Thanks for this last possible "solution". It is true that it has a drawback ! I guess that this workaround must be implemented in the first level of the menu and each of its submenu (as my menu has also submenus). I think we will wait for OO 2.2. Julien Galand - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Enable toolbar items if dynamic protocol handler
Le 3 nov. 06, à 09:59, Carsten Driesner a écrit : Julien Galand wrote: Hi to all, My add-on has a toolbar created by a .xcu file, with the right protocol handler declared (as a node "org.openoffice.Office.ProtocolHandler/HandlerSet" of the configuration file). But there is no component registration in the package; in particular no registration of the implementation of the service of the protocol handler. Instead, the service of the protocol handler is registered dynamically by the executable component of my add-on, therefore necessarily LATER than OO's reading of the .xcu file. => The toolbar items are shown disabled, probably because the protocol handler service couldn't be instanciated at the time the toolbar was created. Is there a way to ask OO to re-scan the toolbar items to bind them to the protocol handler, which will likely make them enabled ? Thank you if you have some hint... Hi Julien, I think the best solution would be to register your service before any user interface element is created. This can be done by a Job which will be activated on application startup. Nevertheless if you want to re-scan toolbar items, you can use the com.sun.star.ui.XUIElementSettings interface. It's available for all configurable user interface elements (menubar, toolbar, statusbar). See the following Basic macro Hi Carsten, It seems that a toolbar created by a .xcu file isn't considered as "configurable". It doesn't appear in the list returned by XLayoutManager.getElements. It is maybe only a UIElement service instead of ConfigurableUIElement. I am sorry that I cannot tell you more information, a colleague is working on this and he has decided to give up that path because of this failure. But would you know where we have failed ? Julien Galand - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[api-dev] Command URL binding between menu and shortcut
Hi to all, I have a menu on which some keyboard shortcuts have been set through ui::XAcceleratorConfiguration. When a shortcut is set with the same command URL of an existing menu line, OO automatically displays the shortcut on the menu line (or should; a bug prevents this, but will be fixed in a later OO version). However, a drawback is that the protocol handler declared for these URLs receives the same URL when the user clicks in the menu and when he strokes the key shortcut. Is there a way to distinguish both kind of events ? I have tried to add arguments to the URL, such as : vnd.MyCompany:command1 for the menu line, vnd.MyCompany:command1?kind=0 for the shortcut, ...hoping that OO would still bind both in the displayed menu, but it is not the case. Does OO do this automatic binding by comparing strictly both URLs, or does it allow some differences while still considering them equal ? Or is there another way ? Thank you if you know any. Julien Galand - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Enable toolbar items if dynamic protocol handler
Le 6 nov. 06, à 16:19, Carsten Driesner a écrit : You want to re-scan a add-on toolbar? Ok, that's why my "solution" doesn't work. An add-on toolbar is not stored in the user interface configuration, it's a part of the normal OpenOffice.org configuration. Therefore it's not a ConfigurableUIElement. The only solution for this would be to destroy and create the toolbar again via layout manager (see Basic macro below) Yes, we have tried this, apparently without success (the whole UI doesn't change). But we should double-check it before concluding anything and submit it to the mailing list again. What about my other proposed solution? Use a job and register your service before any UI is visible. I will remember this solution. I have set it aside for the time being, because a job must be registered again in some OO configuration file (typically in the .xcu of a package), and that is precisely the kind of thing we try to avoid. We want to register everything dynamically. Thank you for these possible solutions. Julien Galand - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Enable toolbar items if dynamic protocol handler
Andreas Schlüns a écrit : Hello Julien, What about my other proposed solution? Use a job and register your service before any UI is visible. I will remember this solution. I have set it aside for the time being, because a job must be registered again in some OO configuration file (typically in the .xcu of a package), and that is precisely the kind of thing we try to avoid. We want to register everything dynamically. They only way to get a notification about the first opened visible document is using of the job mechanism. OK - you can register any UNO listener on the gloabl css.document.GlobalEventBroadcaster instance (such broadcaster provides any notification about loading/storing/changing office documents) ... but how you will trigger your own listener registration ? Hardly coded inside main() ? But there exists a direct binding between the GlobalEventBroadcaster and the job execution. Jobs can be registered for events (e.g. OnStartApp). Of course registration of such jobs can be done using the configuration only. You said (some postings before) you dont install an AddOn .. you wish to patch the office "dynamicly at runtime". How do you do that ? Regards Andreas Hi Andreas, I am sorry to answer so late, I was away for 5 weeks. Yes, I register my add-on dynamically through a system hook, not an official and portable API mechanism (though I would be glad if there were any). That is : - Without any modification of OO configuration file, I detect OO's boot by a system hook. - On some systems (such as Windows), such hooks also enable me to inject any DLL in OO's process (then this DLL executes within OO's process). - Then I must somehow induce OO to register dynamically this DLL as an add-on. Under Windows, I use OLE to do this, the only way I have seen to call OO, since I don't have any reference to OO's service manager at this point. On other systems, maybe it could also be done if OO is scriptable under the corresponding system. - OO registers my DLL and during the call to 'component_getFactory', it passes a reference on its service manager. Done. But it is true that all this processing can only occur quite late after OO's boot, particularly after OO has read its configuration file, and that is the problem mentioned in my previous posts. Julien Galand - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]