ONLYOFFICE / DocumentBuilder

ONLYOFFICE Document Builder is powerful text, spreadsheet, presentation and PDF generating tool
https://www.onlyoffice.com/document-builder.aspx
GNU Affero General Public License v3.0
111 stars 54 forks source link

There might be an issue with oParagraph.Search #130

Open nicewillsuccess opened 4 months ago

nicewillsuccess commented 4 months ago

I'm encountering an issue while using the oParagraph.Search method. When I attempt to bold the entire search result (e.g., "text"), only part of the text, like "tex," is getting bolded instead of the full "text" as I expected.

nicewillsuccess commented 4 months ago

var oDocument = Api.GetDocument(); var oParagraph = oDocument.GetElement(2); var aSearch = oParagraph.Search("text"); aSearch[0].SetBold(true);

askonev commented 3 months ago

@nicewillsuccess bug 66725 has been fixed on version 8.1

Rita-Bubnova commented 1 month ago

Version 8.1.1 is released so I close this issue. Feel free to comment or reopen it if you got further questions.

nicewillsuccess commented 1 week ago

版本 8.1.1 已发布,因此我关闭了此问题。如果您有更多问题,请随时发表评论或重新打开它。

I tried with the new version, but the issue persists. If a line break is added and then oParagraph.Search is used, it will select the line break, and the last text of the search won’t be included. If Delete() is called at this point, it will also delete the line break.

Rita-Bubnova commented 1 week ago

@askonev, Please take a look.

nicewillsuccess commented 1 week ago

var oParagraphLineBreak = oDocument.GetElement( 2); var oRun = Api.CreateRun(); oRun.AddLineBreak(); oParagraphLineBreak.AddElement(oRun); oRun = Api.CreateRun(); oRun.AddText("hello"); oRun.SetFontSize(32); oRun.SetShd("clear", 240, 230, 140); oParagraphLineBreak.AddElement(oRun); var oSearch = oParagraphLineBreak.Search("hello"); oSearch[0].Delete(); This is part of the code. I first added a line break, then added the text 'hello'. When using the Search method to find 'hello', the text returned by Search is '\rhell' instead of 'hello'. When calling Delete, it removes both the line break and 'hell'. @askonev