Page 1 of 1

[Solved] Count property ignored for .uno:GoUp

Posted: Fri Jan 19, 2024 9:58 am
by wanglong

Code: Select all

PropertyValue[] property2 = new PropertyValue[]{new PropertyValue(),new PropertyValue()};
        property2[0].Name = "Count";
        property2[0].Value = 10;
        property2[1].Name = "Select";
        property2[1].Value = true;
xDispatchHelper.executeDispatch(xDispatchProvider, ".uno:GoUp", "", 0, property2);
For example, when I set Count to 10,but it just go up one line.

Re: .uno:GoUp "Count" property is not work for me

Posted: Fri Jan 19, 2024 3:06 pm
by Lupp
General:
1. Never post something in the "Macros ..." sub-forum without telling the language you are using and the module of "our" software (in this case Calc) the macro is made for.
2. If you post code, give a sufficiently complete part of it.
3. Best attach an example file containing the code you are asking about.
4. Be aware of the fact that .uno: commands use their own naming and syntax.
5. If you want to use .uno: commands in a written/edited macro, start your work based on a recorded example. It often can tell you much about the usage.
Specific:
The number of steps in .uno:GoUp is not named "Count" but "By".

Re: .uno:GoUp "Count" property is not work for me

Posted: Mon Jan 22, 2024 5:29 am
by wanglong
I had try to use "By",it has no effect.

Re: .uno:GoUp "Count" property is not work for me

Posted: Mon Jan 22, 2024 6:28 am
by FJCC
This works in OpenOffice Basic

Code: Select all

sub GoupTest
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dim args1(1) as new com.sun.star.beans.PropertyValue
args1(0).Name = "By"
args1(0).Value = 10
args1(1).Name = "Sel"
args1(1).Value = false

dispatcher.executeDispatch(document, ".uno:GoUp", "", 0, args1())
End Sub

Re: .uno:GoUp "Count" property is not work for me

Posted: Mon Jan 22, 2024 7:56 am
by Zizi64
5. If you want to use .uno: commands in a written/edited macro, start your work based on a recorded example. It often can tell you much about the usage.
My addition:
Record (do not write) the recordable macros. Then you can modify them - if it is needed.
But it is better to WRITE the macros based on the API functions. It is a more effective method to control the application and the documents even if the document is in Hidden state.

Re: .uno:GoUp "Count" property is not work for me

Posted: Mon Jan 22, 2024 10:52 am
by wanglong
First of all, I would like to apologize for not being clear enough about the problem and the scenario.
  • First, I'm currently using JAVA to execute .uno: commands via executeDispatch.
  • Second, what you said about the LO/OO BASIC script is also correct when it runs in my environment.
  • Finally, I would like to reiterate the problem I am currently experiencing. I'm having trouble executing the .uno:GoUp command in JAVA. When I control the execution behavior of the command through the "Count/By" property, it does not have the expected effect, and only one line of text is always selected upwards after the command is executed, but in BASIC, this property does take effect.
Is this a bug?

Re: .uno:GoUp "Count" property is not work for me

Posted: Mon Jan 22, 2024 10:58 am
by wanglong
And as I said, I'm having trouble executing .uno:GoUp commands in the way I use the API. So I wanted to do this by using JAVA to control LO to execute BASIC scripts, but I found that I couldn't execute BASIC scripts correctly in documents opened in hidden mode (which works in visible mode), and I'm discussing this in this topic viewtopic.php?p=544614#p544614.

Re: .uno:GoUp "Count" property is not work for me

Posted: Mon Jan 22, 2024 12:46 pm
by DiGro
In Basic:

Code: Select all

Sub Move10Up()
  Dim oViewCursor As Object
  oViewCursor = ThisComponent.CurrentController.getViewCursor()
  oViewCursor.goUp(10, False)
End Sub