[Solved] Control .uno:ExecuteSearch range

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
wanglong
Posts: 51
Joined: Fri Sep 09, 2022 10:57 am
Location: Beijing,China

[Solved] Control .uno:ExecuteSearch range

Post by wanglong »

I want to find&replace some string in a range I want in Writer.

Code: Select all

	PropertyValue[] TMP = new PropertyValue[]{new PropertyValue(),new PropertyValue()};
        TMP[0].Name = "SearchString";
        TMP[0].Value = "Filter";
        TMP[1].Name = "Quiet";
        TMP[1].Value = "false";
        Object oo = xDispatchHelper.executeDispatch(xDispatchProvider, ".uno:ExecuteSearch", "", 0, TMP);
        System.out.println(oo);
        TMP = new PropertyValue[]{new PropertyValue(),new PropertyValue()};
        TMP[0].Name = "Text";
        TMP[0].Value = "Replace";
        oo = xDispatchHelper.executeDispatch(xDispatchProvider, ".uno:InsertText", "", 0, TMP);
        System.out.println(oo);
I can realize find&replace but I don't know how to control the range.I know that I can judge it by TextviewCursor position,which could be get from the result location with execute ".uno:ExecuteSearch".

But I want to know "Is there more convenient way to do this,like UNO API?"
Last edited by MrProgrammer on Fri Jul 14, 2023 3:27 pm, edited 3 times in total.
Reason: Edited topic's subject; wanglong is using .uno:ExecuteSearch not Find &Replace
Libre Office 7.6 on Windows 11.
wanglong
Posts: 51
Joined: Fri Sep 09, 2022 10:57 am
Location: Beijing,China

Re: How to control Find&Replace range?

Post by wanglong »

And Can I judge two TextRange's relative location?
Like A is above B,A is below B in a Writer documentation.
Libre Office 7.6 on Windows 11.
JeJe
Volunteer
Posts: 2779
Joined: Wed Mar 09, 2016 2:40 pm

Re: How to control Find&Replace range?

Post by JeJe »

Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
wanglong
Posts: 51
Joined: Fri Sep 09, 2022 10:57 am
Location: Beijing,China

Re: How to control Find&Replace range?

Post by wanglong »

OK OK!
I made it.
Thk u very much~
Libre Office 7.6 on Windows 11.
Post Reply