|
View:
New views
15 Messages
—
Rating Filter:
Alert me
|
|
|
How to remove toolbars itemsHi,
I am trying to remove toolbars items. I understand how to remove it using LayoutManager. But LayoutManager doesn't save changes to the document storage. I have read http://specs.openoffice.org/ui_in_general/api/ProgrammaticControlOfMenuAndToolbarItems.sxw, where said: [quote] User interface configuration manager retrieved from the document model - Make changes to menu and/or toolbars and store them persistently to the document storage. [/quote]tttt I think it is what I need. I know how to open document. After opening the document, I have XComponent Object. And now, how could I take user interface configuration manager? And how could I, using user interface configuration manager, remove toolbars items? Thank you in advance for your kind reply -- -- .''`. With best regards, : :' : Alexander Anisimov `. `' JID alexanis@... `- Debian - when you have better things to do than fixing systems |
|
|
Re: How to remove toolbars itemsHello Alexander,
On Friday 02 October 2009, 00:19, Alexander Anisimov wrote: > Hi, > > I am trying to remove toolbars items. I understand how to remove it using > LayoutManager. But LayoutManager doesn't save changes to the document > storage. you need the com.sun.star.ui.UIConfigurationManager > I have read > http://specs.openoffice.org/ui_in_general/api/ProgrammaticControlOfMenuAndT > oolbarItems.sxw, where said: > > [quote] > User interface configuration manager retrieved from the document model - > Make changes to menu and/or toolbars and store them persistently to the > document storage. > [/quote]tttt > > I think it is what I need. > > I know how to open document. After opening the document, I have XComponent > Object. And now, how could I take user interface configuration manager? the document implements the com.sun.star.ui.XUIConfigurationManagerSupplier Invoke XUIConfigurationManagerSupplier.getUIConfigurationManager() to access the document's UIConfigurationManager > how could I, using user interface configuration manager, remove toolbars > items? I understood you are talking here about a document UI, not a module level. If so, then there are two main scenarios: * if the document has already a modified toolbar, you can access it by its resource URL * if the document does not have a customized version of the toolbar you want to modify, then you have to access the toolbar configuration at the module level, and insert the modified version on the document. I do this by getting a writable copy of the module toolbar, so that I con modify it, and then I don't store this changes at the module level but at the document level (I guess that a cleaner approach would be to ask for a read-only copy of the module config. and make an own copy item by item...) Look for sample code at http://arielch.fedorapeople.org/docs/com.sun.star.ui.XUIConfigirationManager.odt Regards -- Ariel Constenla-Haile La Plata, Argentina --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: How to remove toolbars itemsHello Ariel,
Thanks for your answer. 2009/10/11 Ariel Constenla-Haile <ariel.constenla.haile@...> > I understood you are talking here about a document UI, not a module level. > Yes, you are quite right. I have looked this sample. Its very useful for me. But there is problem: When you getting document configuration manager, it looks like Dim oDoc as Object > oDoc = ThisComponent > > Dim oUIConfigurationManager as Object > oUIConfigurationManager = oDoc.getUIConfigurationManager() > but I am writing application in Java. And I can not understand how to get this configuration manager. XComponentContext xContext = Bootstrap.bootstrap(); > XMultiComponentFactory xMCF = xContext.getServiceManager(); > Object oDesktop = > xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", xContext); > XComponentLoader xCLoader = (XComponentLoader) > UnoRuntime.queryInterface(XComponentLoader.class, oDesktop); > PropertyValue[] szEmptyArgs = new PropertyValue[0]; > XComponent Doc = xCLoader.loadComponentFromURL("private:factory/swriter", > "_blank", 0, szEmptyArgs); > And now, how to get configuration manager. There is no getUIConfiguratinManager method in Doc. I know how to get module configuration manager. It is very simple XMultiServiceFactory xmsf = getMultiServiceFactory(xMCF, xContext); > Object o = > xmsf.createInstance("com.sun.star.ui.ModuleUIConfigurationManagerSupplier"); > XModuleUIConfigurationManagerSupplier xmuicms = > (XModuleUIConfigurationManagerSupplier) > UnoRuntime.queryInterface(XModuleUIConfigurationManagerSupplier.class, o); > XUIConfigurationManager xuicm = > xmuicms.getUIConfigurationManager("com.sun.star.text.TextDocument"); > Thank you in advance for your kind reply -- -- .''`. With best regards, : :' : Alexander Anisimov `. `' JID alexanis@... `- Debian - when you have better things to do than fixing systems |
|
|
Re: How to remove toolbars itemsHello Alexander,
On Saturday 10 October 2009, 21:30, Alexander Anisimov wrote: > > I understood you are talking here about a document UI, not a module > > level. > > Yes, you are quite right. > > I have looked this sample. Its very useful for me. But there is problem: > > When you getting document configuration manager, it looks like > > Dim oDoc as Object > > > oDoc = ThisComponent > > > > Dim oUIConfigurationManager as Object > > oUIConfigurationManager = oDoc.getUIConfigurationManager() > > but I am writing application in Java. And I can not understand how to get > this configuration manager. sorry, I was too lazy to write something new in Java, I just copied and pasted some OOo Basic code I have. First lesson in OOo API must be: learn how to use the API reference. So, you don't know how to get access to this method getUIConfigurationManager()? then search for it in the global index: http://api.openoffice.org/docs/common/ref/index-files/index-7.html there you find two methods: getUIConfigurationManager() - function in interface ::com::sun::star::ui:: .XUIConfigurationManagerSupplier getUIConfigurationManager() - function in interface ::com::sun::star::ui:: .XModuleUIConfigurationManagerSupplier the names of the interfaces tell you everything: the one with xxxModulexxx is for accessing the global UI configuration. ::com::sun::star::ui:: XUIConfigurationManagerSupplier is implemented by the documents. So query this last interface on the object you get with loadComponentFromURL(), check the reference is not null, and then invoke getUIConfigurationManager() > XComponentContext xContext = Bootstrap.bootstrap(); > > > XMultiComponentFactory xMCF = xContext.getServiceManager(); > > Object oDesktop = > > xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", xContext); > > XComponentLoader xCLoader = (XComponentLoader) > > UnoRuntime.queryInterface(XComponentLoader.class, oDesktop); > > PropertyValue[] szEmptyArgs = new PropertyValue[0]; > > XComponent Doc = xCLoader.loadComponentFromURL("private:factory/swriter", > > "_blank", 0, szEmptyArgs); > > And now, how to get configuration manager. There is no > getUIConfiguratinManager method in Doc. you get by loadComponentFromURL() an object that implements XComponent. On that object you have to query all the interfaces it is supposed to implement (or all interfaces you intend to use, if the object does not implement it, you'll get a null reference). In your case, query XUIConfigurationManagerSupplier As it may be quite difficult to remember all interfaces an object implements, for learning the OOo API you may find useful a tool called Xray that can introspect every object in OOo API. Regards -- Ariel Constenla-Haile La Plata, Argentina --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: How to remove toolbars itemsHello Ariel,
Thanks for your answer. Now I understand how to work with UIConfigureManager. And I have once more question. I your sample, you remove some settings, and then insert all the rest. If nIndex >= 0 Then > oToolbarSettings.removeByIndex(nIndex) > If bCreate Then > oUIConfigurationManager.insertSettings(sResourceURL, > oToolbarSettings) > Else > oUIConfigurationManager.replaceSettings(sResourceURL, > oToolbarSettings) > End If > 'make changes persist at the doc storage, NOT globally!!! > oUIConfigurationManager.store() > End If But I try to change "IsVisible" property and then replace settings If nIndex >= 0 Then > Dim oToolBarButton() As Object > Dim nToolBarButtonCount As Integer > Dim j As Integer > oToolBarButton() = oToolbarSettings.getByIndex(nIndex) > nToolBarButtonCount = ubound(oToolBarButton()) > for j = 0 to nToolBarButtonCount > If oToolBarButton(j).Name = "IsVisible" Then > oToolBarButton(j).Value = "false" > End If > next j > oToolbarSettings.replaceByIndex(nIndex, oToolBarButton()) > If bCreate Then > oUIConfigurationManager.insertSettings(sResourceURL, > oToolbarSettings) > Else > oUIConfigurationManager.replaceSettings(sResourceURL, > oToolbarSettings) > End If > 'make changes persist at the doc storage, NOT globally!!! > oUIConfigurationManager.store() > End If > And this code does not work. Do you know why? Thank you in advance for your kind reply -- -- .''`. With best regards, : :' : Alexander Anisimov `. `' JID alexanis@... `- Debian - when you have better things to do than fixing systems |
|
|
Re: How to remove toolbars itemsHello Ariel,
I found my mistake. I should not set value as a string, it is an Object. So, this code works :) If nIndex >= 0 Then Dim oToolBarButton() As Object Dim nToolBarButtonCount As Integer Dim j As Integer oToolBarButton() = oToolbarSettings.getByIndex( > > nIndex) > nToolBarButtonCount = ubound(oToolBarButton()) > for j = 0 to nToolBarButtonCount > If oToolBarButton(j).Name = "IsVisible" Then > oToolBarButton(j).Value = false > End If > next j > oToolbarSettings.replaceByIndex(nIndex, oToolBarButton()) > If bCreate Then > oUIConfigurationManager.insertSettings(sResourceURL, > oToolbarSettings) > Else > oUIConfigurationManager.replaceSettings(sResourceURL, > oToolbarSettings) > End If > 'make changes persist at the doc storage, NOT globally!!! > oUIConfigurationManager.store() > End If -- -- .''`. With best regards, : :' : Alexander Anisimov `. `' JID alexanis@... `- Debian - when you have better things to do than fixing systems |
|
|
Re: How to remove toolbars itemsHello Ariel,
I have one more question. I think it last question. Now I know how to operate with toolbar items. But I need to know how to hide or show some toolbar and then save it in document storage. As I understand it should looks like Sub Hide_Standard_Toolbar() > Dim oDoc As Object > Dim oFrame > Dim element > Dim layoutmanager > > oDoc = ThisComponent > > Dim oUIConfigurationManager as Object > oUIConfigurationManager = oDoc.getUIConfigurationManager() > > oFrame = oDoc.getCurrentController().getFrame() > layoutmanager = oFrame.LayoutManager > > element = > layoutmanager.getElement("private:resource/toolbar/standardbar") > element.ConfigurationSource = oUIConfigurationManager element.Persistent = true > > layoutmanager.hideElement("private:resource/toolbar/standardbar") > End Sub > But this code hide standard toolbar in global storage, although I have changed ConfigurationSource to document storage. I don't understand why. Thank you in advance for your kind reply -- -- .''`. With best regards, : :' : Alexander Anisimov `. `' JID alexanis@... `- Debian - when you have better things to do than fixing systems |
|
|
Re: How to remove toolbars itemsHello Alexander,
On Monday 12 October 2009, 01:50, Alexander Anisimov wrote: > Hello Ariel, > > I have one more question. I think it last question. > > Now I know how to operate with toolbar items. But I need to know how to > hide or show some toolbar and then save it in document storage. do you want to save the visibility state inside the document? AFAIK this isn't possible. I'm just an API client, so the following is just "guessing" (Carsten Diesner usually reads this mailing list, sure the mail subject catches his attention; he could give you a better advice, as he developed the code). * as far as I could see, the window state configuration is stored globally; even if the doc has its own UI elements, as long as they are persistent, their window state is stored globally, per module > Sub Hide_Standard_Toolbar() > > > Dim oDoc As Object > > Dim oFrame > > Dim element > > Dim layoutmanager > > > > oDoc = ThisComponent > > > > Dim oUIConfigurationManager as Object > > oUIConfigurationManager = oDoc.getUIConfigurationManager() > > > > oFrame = oDoc.getCurrentController().getFrame() > > layoutmanager = oFrame.LayoutManager > > > > element = > > layoutmanager.getElement("private:resource/toolbar/standardbar") > > element.ConfigurationSource = oUIConfigurationManager * does this switch the storage? I mean, if the toolbar wasn't stored in the document, changing the configuration source copies the module toolbar into the document storage? I didn't try if this works. > element.Persistent = true * you should do the opposite: setting this to true stores the window state at the module level cf. http://svn.services.openoffice.org/opengrok/xref/DEV300_m61/framework/source/layoutmanager/layoutmanager.cxx#1545 spec. 1573 I'd try the following: * do not access the toolbar by the LayoutManager and then change the ConfigurationSource. Use the way you already learn by getting it from the configuration manager (first try to see if the document already has a customized version in its storage; if not, get it from the module ui config. manager, and copy it in the document ui config. manager). You can make a helper method getToolbar(sResourceURL) for this. This way you make sure that you're always working with the toolbar at document level, not module. * now fool the LayoutManager to set it not visible without storing the window state information: Dim oLayoutManager as Object oLayoutManager = oDoc.getCurrentController().getFrame().getPropertyValue("LayoutManager") Dim oUIElement as Object oUIElement = oLayoutManager.getElement(OOO_WRITER_STANDARD_TOOLBAR) 'Fool the LayoutManager oUIElement.Persistent = False oLayoutManager.hideElement(OOO_WRITER_STANDARD_TOOLBAR) 'Set it Persistent again oUIElement.Persistent = True I've updated the doc with a new sub http://arielch.fedorapeople.org/docs/com.sun.star.ui.XUIConfigirationManager.odt I didn't test much, but that trick seems to work. Regards -- Ariel Constenla-Haile La Plata, Argentina --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: How to remove toolbars itemsAriel Constenla-Haile wrote:
> Hello Alexander, > > On Monday 12 October 2009, 01:50, Alexander Anisimov wrote: >> Hello Ariel, >> >> I have one more question. I think it last question. >> >> Now I know how to operate with toolbar items. But I need to know how to >> hide or show some toolbar and then save it in document storage. > > do you want to save the visibility state inside the document? > AFAIK this isn't possible. > > I'm just an API client, so the following is just "guessing" (Carsten Diesner > usually reads this mailing list, sure the mail subject catches his attention; > he could give you a better advice, as he developed the code). > > * as far as I could see, the window state configuration is stored globally; > even if the doc has its own UI elements, as long as they are persistent, their > window state is stored globally, per module The visibility state cannot be stored in the document. This was a design decision by the UX team several years ago. The visibility state should always follow the user settings. That means if the user sets a toolbar to invisible it's a violation of user experience to make it visible again. > >> Sub Hide_Standard_Toolbar() >> >>> Dim oDoc As Object >>> Dim oFrame >>> Dim element >>> Dim layoutmanager >>> >>> oDoc = ThisComponent >>> >>> Dim oUIConfigurationManager as Object >>> oUIConfigurationManager = oDoc.getUIConfigurationManager() >>> >>> oFrame = oDoc.getCurrentController().getFrame() >>> layoutmanager = oFrame.LayoutManager >>> >>> element = >>> layoutmanager.getElement("private:resource/toolbar/standardbar") >>> element.ConfigurationSource = oUIConfigurationManager change the configuration source of an active user interface element. The layout manager can destroy and create the elements whenever the user interface context changes. So your solution would only work temporary. Please use the way Ariel describes below. > > * does this switch the storage? I mean, if the toolbar wasn't stored in the > document, changing the configuration source copies the module toolbar into the > document storage? I didn't try if this works. > >> element.Persistent = true > > * you should do the opposite: setting this to true stores the window state at > the module level cf. > http://svn.services.openoffice.org/opengrok/xref/DEV300_m61/framework/source/layoutmanager/layoutmanager.cxx#1545 > spec. 1573 > > I'd try the following: > > * do not access the toolbar by the LayoutManager and then change the > ConfigurationSource. Use the way you already learn by getting it from the > configuration manager (first try to see if the document already has a customized > version in its storage; if not, get it from the module ui config. manager, and > copy it in the document ui config. manager). You can make a helper method > getToolbar(sResourceURL) for this. > This way you make sure that you're always working with the toolbar at document > level, not module. configuration manager whenever you want to make persistent changes to the content of a user interface element. Non-persistent changes can be done by using the layout manager to retrieve the ui element. > > * now fool the LayoutManager to set it not visible without storing the window > state information: > > Dim oLayoutManager as Object > oLayoutManager = > oDoc.getCurrentController().getFrame().getPropertyValue("LayoutManager") > Dim oUIElement as Object > oUIElement = oLayoutManager.getElement(OOO_WRITER_STANDARD_TOOLBAR) > 'Fool the LayoutManager > oUIElement.Persistent = False > oLayoutManager.hideElement(OOO_WRITER_STANDARD_TOOLBAR) > 'Set it Persistent again > oUIElement.Persistent = True > > I've updated the doc with a new sub > http://arielch.fedorapeople.org/docs/com.sun.star.ui.XUIConfigirationManager.odt > > I didn't test much, but that trick seems to work. future. "Persistent" is a property which influences the persistence of the content of a ui element. It's not designed to influence other attributes (like visibility), although the current implementation respects it. Regards, Carsten -- Carsten Driesner (cd) - Project Lead OpenOffice.org Framework Framework wiki: http://wiki.services.openoffice.org/wiki/Framework OpenOffice.org Engineering at Sun: http://blogs.sun.com/GullFOSS --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: java MailMerger for open office 3.1.1Dear Ted,
I wonder why nobody is responding to your issue. This is an issue I also raised just before the summer holiday, but it was hard to get any help. It seems the real OOo-specialists worry more about minor issues like removing toolbar items then major real world wordprocessor issues like mailmerge. Dear Frank, You were the only one really trying to help me this summer. Unfortunately I had already invested too much time on this mailmerge issue, so my boss did not allow me to continue wasting his money and we solved the issue without using OpenOffice, which I still regret. Can't you help Ted? He probably can provide you with ready to test code, which I could not. Kind regards, René ----------------------------------------------------------------------------------- i-Modulas Software BV Nikkelstraat 6, 2984 AM Ridderkerk / NL Tel. (+31) (0)88 0900 902 / Pers.fax (+31) (0)13 505 6132 Email r.van.oevelen@... Website www.i-modulas.nl ----------------------------------------------------------------------------------- --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: How to remove toolbars itemsHello Ariel and Carsten,
Thanks for your answer. It's a pity that visibility state of toolbars cannot be stored in the document. :( So, I would try to write two app. The first will configure toolbars items and store it in document store. And the second will load this document and check, if some toolbar has not any items, then using LayoutManager, set persistent to false and hide it. -- -- .''`. With best regards, : :' : Alexander Anisimov `. `' JID alexanis@... `- Debian - when you have better things to do than fixing systems |
|
|
Re: How to remove toolbars itemsHi Carsten
On Mon, 2009-10-12 at 14:56 +0200, Carsten Driesner wrote: > The visibility state cannot be stored in the document. This was a > design > decision by the UX team several years ago. > The visibility state should > always follow the user settings. That means if the user sets a > toolbar > to invisible it's a violation of user experience to make it visible > again. Is there any plans to change that? I mean I can understand this rationale for global/user settings for toolbars that are document specific ( e.g. stored in the document ) But... having the visibility state of document specific toolbars stored locally on the file system ( to my mind ) makes no sense. Bear in mind it's not just the visibility state that is stored but also the positioning, so, with the current system if you have a document that you want to store some custom functionality exposed via a toolbar ( you cannot specify the desired position or initial visibility state of that toolbar ) Furthermore if someone opens that document they could hide the toolbar ( or move it into a position where not all toolbar items are easily visible etc. ) The next time that user opens the document those ( in this case erroneous ) changes would be applied, surely those changes should/could be stored with the document? at least then if the document was not modified the positional and visibility attributes would be in a consistent state? Noel --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: How to remove toolbars itemsOn Tue, 2009-10-13 at 10:11 +0100, Noel Power wrote:
> Is there any plans to change that? I mean I can understand this > rationale for global/user settings for toolbars that are document > specific ( e.g. stored in the document ) But... having the visibility > state of document specific toolbars stored locally on the file system > ( to my mind ) makes no sense rewording... Are there any plans to change that? I mean I can understand the rationale for global/user settings for toolbars for application settings. But for toolbars that are document specific ( e.g. stored in the document ) having the visibility state of document specific toolbars stored locally on the file system ( to my mind ) makes no sense. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: How to remove toolbars itemsNoel Power wrote:
> On Tue, 2009-10-13 at 10:11 +0100, Noel Power wrote: >> Is there any plans to change that? I mean I can understand this >> rationale for global/user settings for toolbars that are document >> specific ( e.g. stored in the document ) But... having the visibility >> state of document specific toolbars stored locally on the file system >> ( to my mind ) makes no sense > rewording... > > Are there any plans to change that? I mean I can understand the > rationale for global/user settings for toolbars for application > settings. But for toolbars that are document specific ( e.g. stored in > the document ) having the visibility state of document specific > toolbars stored locally on the file system ( to my mind ) makes no > sense. According to my knowledge there are no such plans. I can understand your arguments but the user experience team decided that the state of EVERY toolbar should be user specific. You could store the visibility of every toolbar in a document and hide/show it although the user decided otherwise. That's the reason why user experience decided against this solution. The current design uses the configuration to store the position, visibility and other attributes. A natural enhancement would use a configuration provider which can read/write configuration files from a document. There is no such configuration provider and writing one is not an easy task. Therefore, from my point of view, changing this behavior in a good way needs some work to do. Currently I see no chance to implement it in the near future. Regards, Carsten --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: java MailMerger for open office 3.1.1Hello René,
On Monday 12 October 2009, 10:47, René van Oevelen wrote: > Dear Ted, > > I wonder why nobody is responding to your issue. > This is an issue I also raised just before the > summer holiday, but it was hard to get any help. > It seems the real OOo-specialists worry more > about minor issues like removing toolbar items this is no minor issue, at least not for the one that had the problem and tried to solved it, looking for help here. Regards -- Ariel Constenla-Haile La Plata, Argentina --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
| Free embeddable forum powered by Nabble | Forum Help |