[Solved] Function for Search Bar (Ctrl+F)

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
linuxyz
Posts: 10
Joined: Sat Mar 03, 2018 10:53 am

[Solved] Function for Search Bar (Ctrl+F)

Post by linuxyz »

Hi!
I've found the function to display the search dialog (triggered by Ctrl+H), it's

Code: Select all

.uno:SearchDialog
like in :

Code: Select all

dispatcher.executeDispatch(document, ".uno:SearchDialog", "", 0, Array())
But I haven't found the function to display the search bar, at the bottom (triggered by Ctrl+F), Does it exist?

Thanks a lot in advance!
Last edited by linuxyz on Sun Mar 04, 2018 11:47 am, edited 1 time in total.
openoffice 4.1.14 on Arch Linux (Cinnamon desktop)
User avatar
Zizi64
Volunteer
Posts: 11352
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Function for Search Bar (Ctrl+F)

Post by Zizi64 »

But I haven't found the function to display the search bar, at the bottom (triggered by Ctrl+F), Does it exist?

Thanks a lot in advance!
openoffice 4.1.5-1 on Linux Arch

Are you using the LibreOffice?
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Function for Search Bar (Ctrl+F)

Post by Villeroy »

Run this against some spreadsheet document. It generates a new spreadsheet with all availlable spreadsheet dispatches. Can be used with any other type of frame as well.

Code: Select all

Sub fetchDispatchInformation()
REM dump current frame's "ConfigurableDispatchInformation" into a new spreadsheet as hyperlinks
REM if the current frame happens to be a spreadsheet frame, you can test the hyperlinks
  Dim oCurrentController As Variant
  Dim oFrame As Variant
  Dim oConfigurableDispatchInformation As Variant
  Dim oConfigurableDispatchInformation2 As Variant
  Dim oConfigurableDispatchInformation3 As Variant

  oCurrentController = ThisComponent.getCurrentController()
  oFrame = oCurrentController.getFrame()
	oDoc = StarDesktop.loadComponentFromURL("private:factory/scalc","_blank",0,Array())
	sh = oDoc.Sheets.getByIndex(0)
	c = 0

on error goto exitErr
do
  oConfigurableDispatchInformation = oFrame.getConfigurableDispatchInformation(c)
	for each p in oConfigurableDispatchInformation
		sh.getCellByPosition(c,r).setFormula("=HYPERLINK("""& p.Command &""")")
		r = r +1
	next p
  c = c +1
  r = 0
loop
exitErr:
End Sub
Made with a little help from my friend: [Tutorial] Introduction into object inspection with MRI
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Function for Search Bar (Ctrl+F)

Post by Villeroy »

It is vnd.sun.star.findbar:FocusToFindbar
I found it in <profile>/config/soffice.cfg/modules/scalc/menubar/menubar.xml
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
linuxyz
Posts: 10
Joined: Sat Mar 03, 2018 10:53 am

Re: Function for Search Bar (Ctrl+F)

Post by linuxyz »

Thanks a lot! I'm almost there though... How do you call it in the script?
I've tried :

Code: Select all

dispatcher = createUnoService("com.sun.star.frame.DispatchHelper", "", 0, Array())
dispatcher.executeDispatch(document, ".uno:FocusToFindbar", "", 0, Array())
But that's not the right thing evidently... I'm still very new to macro script, sorry.
openoffice 4.1.14 on Arch Linux (Cinnamon desktop)
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Function for Search Bar (Ctrl+F)

Post by Villeroy »

The url is "vnd.sun.star.findbar:FocusToFindbar".
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
linuxyz
Posts: 10
Joined: Sat Mar 03, 2018 10:53 am

Re: Function for Search Bar (Ctrl+F)

Post by linuxyz »

Sorry, I didn't changed that.
I've tried:

Code: Select all

dim dispatcher as object
dim document as object
document = ThisComponent.CurrentController.Frame

dispatcher = createUnoService("vnd.sun.star.findbar", "", 0, Array())
dispatcher.executeDispatch(document, ".uno:FocusToFindbar", "", 0, Array())
But I get for the last line:

Code: Select all

"object variable not set
how do I call this function?
openoffice 4.1.14 on Arch Linux (Cinnamon desktop)
User avatar
Zizi64
Volunteer
Posts: 11352
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Function for Search Bar (Ctrl+F)

Post by Zizi64 »

Please upload the full code of the subroutine (or a sample ODF file with the embedded macro).


Are you using the "Option explicit" at the begin of the Module?
If the answer is Yes, then you need declare the variable Array() too.


How to get the dispacher:

Code: Select all

dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
linuxyz
Posts: 10
Joined: Sat Mar 03, 2018 10:53 am

Re: Function for Search Bar (Ctrl+F)

Post by linuxyz »

Phew! Eventually I've got it right!
Thanks @Zizi64 and @Villeroy for the help.

Here's the code working:

Code: Select all

Sub test_findbar
dim document as object
dim dispatcher as object

dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dispatcher.executeDispatch(document, "vnd.sun.star.findbar:FocusToFindbar", "", 0, Array())
End Sub
openoffice 4.1.14 on Arch Linux (Cinnamon desktop)
User avatar
RoryOF
Moderator
Posts: 34586
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: [SOLVED] Function for Search Bar (Ctrl+F)

Post by RoryOF »

Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
linuxyz
Posts: 10
Joined: Sat Mar 03, 2018 10:53 am

Re: [SOLVED] Function for Search Bar (Ctrl+F)

Post by linuxyz »

Nobody answered there (I've tried the mailing list too, without success). I could have deleted the post there but I thought it better not deleting it for future users...
openoffice 4.1.14 on Arch Linux (Cinnamon desktop)
User avatar
Hagar Delest
Moderator
Posts: 32627
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: [Solved] Function for Search Bar (Ctrl+F)

Post by Hagar Delest »

Of course this discussion should be kept since you got your help here. This is indeed expected to be a knowledge database.
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
Post Reply