| View previous topic :: View next topic |
| Author |
Message |
PBiela Power User


Joined: 10 Feb 2004 Posts: 56 Location: Frankfurt/Main Germany
|
Posted: Wed Mar 17, 2004 3:03 am Post subject: HowTo Toggle VisibleBars on open Documents |
|
|
Hello folks,
a quick way to change the display status of all the bars in a open frame is this:
It toggles the visible status between True and False
| Code: |
oFrame = ThisComponent.CurrentController.Frame
Dim noArgs1()
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dispatcher.executeDispatch(oFrame, ".uno:MenuBarVisible", "", 0, noArgs1())
dispatcher.executeDispatch(oFrame, ".uno:ObjectBarVisible", "", 0, noArgs1())
dispatcher.executeDispatch(oFrame, ".uno:OptionBarVisible", "", 0, noArgs1())
dispatcher.executeDispatch(oFrame, ".uno:NavigationBarVisible", "", 0, noArgs1())
dispatcher.executeDispatch(oFrame, ".uno:StatusBarVisible", "", 0, noArgs1())
dispatcher.executeDispatch(oFrame, ".uno:ToolBarVisible", "", 0, noArgs1())
dispatcher.executeDispatch(oFrame, ".uno:MacroBarVisible", "", 0, noArgs1())
dispatcher.executeDispatch(oFrame, ".uno:FunctionBarVisible", "", 0, noArgs1())
'on CalcFrames
dispatcher.executeDispatch(oFrame, ".uno:InputLineVisible", "", 0, noArgs1())
|
Can be handy when delivering end-user forms with built in navigation / controls.
A quick way to switch the visible status of the whole window or the context of the window is this:
| Code: |
'Hides the whole Window of the Frame
oFrame.ContainerWindow.Visible = False
'Hides the whole Context of the Frame (Charts, Text, CaldSheets)
oFrame.ComponentWindow.Visible = False
|
I hope this code can get usefull for somebody.
This Link shows all the usefull Uno Comands working in OOo 1.1 beta
http://framework.openoffice.org/files/documents/25/1042/commands_11beta.html
Peter Biela _________________
Who is John Galt? - Ayn Rand  |
|
| Back to top |
|
 |
JohnV Administrator

Joined: 07 Mar 2003 Posts: 8984 Location: Lexinton, Kentucky, USA
|
Posted: Wed Mar 17, 2004 4:50 am Post subject: |
|
|
Peter,
Thanks for this great reference link. |
|
| Back to top |
|
 |
PBiela Power User


Joined: 10 Feb 2004 Posts: 56 Location: Frankfurt/Main Germany
|
Posted: Wed Mar 17, 2004 6:10 am Post subject: |
|
|
I'm allways very, very, very happy when I find anything usefull in the API documentation!
 |
|
| Back to top |
|
 |
Cybb20 Super User


Joined: 02 Mar 2004 Posts: 1569 Location: Frankfurt, Germany
|
Posted: Sun Nov 07, 2004 1:54 pm Post subject: |
|
|
If you found this to be useful, then you probably don't want to miss this feature:
http://www.oooforum.org/forum/viewtopic.php?t=13986
You can then detect if certain toolbars are visible or not and decide upon the certain condition.
Christian _________________ - Knowledge is Power - |
|
| Back to top |
|
 |
Gore General User

Joined: 13 May 2005 Posts: 13 Location: Andalucía
|
Posted: Fri May 13, 2005 11:50 am Post subject: How to set display status of bars |
|
|
A way to set (or change) the display status of any bar.
Parameter sBar is the string name: ""MenuBarVisible" , "ObjectBarVisible", "OptionBarVisible", "NavigationBarVisible", "StatusBarVisible", "ToolBarVisible",
"MacrobarVisible", "FunctionBarVisible" or "InputLineVisible"
Parameter bOnOff True set the bar visible, False no visible; if missing it changes the display status.
| Code: | Sub BarOnOff(sBar As String, Optional bOnOff As Boolean)
Dim oFrame As Object
Dim oDispatch As Object
Dim args(0) As new com.sun.star.beans.PropertyValue
oFrame = ThisComponent.CurrentController.Frame
If Not(IsMissing(bOnOff)) Then
args(0).Name = sBar
args(0).Value = bOnOff
Endif
oDispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
oDispatcher.executeDispatch(oFrame, ".uno:" + sBar, "", 0, args())
End Sub |
Elías |
|
| Back to top |
|
 |
Cybb20 Super User


Joined: 02 Mar 2004 Posts: 1569 Location: Frankfurt, Germany
|
Posted: Sun May 15, 2005 2:29 pm Post subject: |
|
|
With the new API for upcoming OOo 2.0 stable release, things will get much easier. Also there is much more control over almost every single item of the UI for OOo.
To not say too much, I will show you how easy it is to make all menubars/toolbars of the current component invisible:
| Code: |
frame = thisComponent.CurrentController.Frame
layout = frame.LayoutManager
layout.setVisible(False) |
Three lines, that's it. No dispatch call, pure API coding.
Christian _________________ - Knowledge is Power - |
|
| Back to top |
|
 |
ddorange General User

Joined: 29 Dec 2002 Posts: 13 Location: France
|
Posted: Sat Jun 11, 2005 7:30 am Post subject: |
|
|
The following macro allows to hide or display a custom toolbar (OOo2.0)
Sub ToSeeorNotToSeeThatIsThequestion
oFrame = ThisComponent.CurrentController.Frame
layout = oFrame.LayoutManager
sUrl="private:resource/toolbar/custom_toolbar_1"
If layout.IsElementVisible(sUrl) Then
layout.hideElement(sUrl)
Else
layout.showElement(sUrl)
Endif
End Sub |
|
| Back to top |
|
 |
James Miles General User

Joined: 28 Nov 2005 Posts: 22 Location: Perth - Australia
|
Posted: Mon Nov 28, 2005 9:01 am Post subject: Hidding Toolbars. |
|
|
Hi Guys,
I've just downloaded OpenOffice.org 2.0.
I'm been reading these forums and have been trying to use .NET to fire up open office & then hide all the tool bars. I've ported some python code i saw in one of these post to execute dispatch, and hide the tool bars. Its very similar to the code in this post.
The code for starting open office is working, it writes hello word into the instance of writer that appears. The hide toolbar code isn't working. I'm trying to do this by using executeDispatch.
Is there a better way of doing this? Am i way off track?
------------------------------------------------------------------------------------------------------
[STAThread]
static void Main()
{
//... i have removed the working code.
// Get the document contoller.
object docController = doc.GetType().InvokeMember("getCurrentController", BindingFlags.InvokeMethod, null, doc, noargs);
// Ge the current frame.
object oframe = docController.GetType().InvokeMember("getFrame", BindingFlags.InvokeMethod, null, docController, noargs);
// Get the dispatch helper.
object[] param = new object[1];
param[0] = "com.sun.star.frame.DispatchHelper";
object dispatcher = (Object)t_OOo.InvokeMember("createInstance", BindingFlags.InvokeMethod, null, objServiceManager, param);
ExecuteDispatch(dispatcher, oframe, ".uno:ToolBarVisible");
ExecuteDispatch(dispatcher, oframe, ".uno:ObjectBarVisible");
ExecuteDispatch(dispatcher, oframe, ".uno:OptionBarVisible");
ExecuteDispatch(dispatcher, oframe, ".uno:NavigationBarVisible");
ExecuteDispatch(dispatcher, oframe, ".uno:StatusBarVisible");
ExecuteDispatch(dispatcher, oframe, ".uno:MenuBarVisible");
ExecuteDispatch(dispatcher, oframe, ".uno:MacroBarVisible");
ExecuteDispatch(dispatcher, oframe, ".uno:FunctionBarVisible");
}
private static void ExecuteDispatch(object dispatcher, object oframe, string methodName)
{
object[] noargs = new object[] {};
object[] dispatcherArgs = new object[5];
dispatcherArgs[0] = oframe;
dispatcherArgs[1] = methodName;
dispatcherArgs[2] = "";
dispatcherArgs[3] = 0;
dispatcherArgs[4] = noargs;
dispatcher.GetType().InvokeMember("executeDispatch", BindingFlags.InvokeMethod, null, dispatcher, dispatcherArgs);
} |
|
| Back to top |
|
 |
LarsB OOo Advocate


Joined: 31 Aug 2005 Posts: 445 Location: Hamburg, Germany
|
Posted: Mon Nov 28, 2005 1:17 pm Post subject: Hide Main Menu |
|
|
Hi James,
i've coded a little test app that show you how to
disable the main menu.
http://www.oooforum.org/forum/viewtopic.phtml?t=27864
Cheers
Lars B
PS: Don't know why the Dispatcher wouldn't work, but i have had
smilar problems. So that i try to avoid using the dispatcher functionality. _________________ AODC - A free OpenDocument Converter
AODL - An independent OpenDocument Library C#
EmbeddedOpenOffice .net UserControl C#
EmbeddedOpenOffice Visual Studio .net Add In
http://www.OpenDocument4all.com/ |
|
| Back to top |
|
 |
MattStark Newbie

Joined: 09 Apr 2008 Posts: 1
|
Posted: Wed Apr 09, 2008 1:08 pm Post subject: C# ... hacked this up today ... |
|
|
What you need to do to get the object:
unoidl.com.sun.star.uno.XComponentContext localContext = uno.util.Bootstrap.bootstrap();
unoidl.com.sun.star.lang.XMultiServiceFactory multiServiceFactory = (unoidl.com.sun.star.lang.XMultiServiceFactory)localContext.getServiceManager();
XComponentLoader componentLoader = (XComponentLoader)multiServiceFactory.createInstance("com.sun.star.frame.Desktop");
XFrame frame = ((unoidl.com.sun.star.text.XTextDocument)xComponent).getCurrentController().getFrame();
XDispatchHelper xDispatchHelper = (XDispatchHelper)multiServiceFactory.createInstance("com.sun.star.frame.DispatchHelper");
Create property values here … and put em in tableArgs ...
xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:InsertTable", "", 0, tableArgs);
 |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|