Bug 153272 - Writer Macro Find with certain Search Attributes performs Replacement.
Summary: Writer Macro Find with certain Search Attributes performs Replacement.
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
7.3.4.2 release
Hardware: All Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:7.6.0 target:7.5.1
Keywords:
Depends on:
Blocks:
 
Reported: 2023-01-30 00:54 UTC by Don
Modified: 2023-03-24 14:29 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments
Test Document with Macro as described in Bug report. (10.91 KB, application/vnd.oasis.opendocument.text)
2023-01-30 00:57 UTC, Don
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Don 2023-01-30 00:54:36 UTC
Description:
When Setting the following Search Attributes singly, (I have not tried combining them), the FindAll or FindFirst Macro command performs a Replace command. See Macro pasted below.




Steps to Reproduce:
1.Open a new Writer Document
2.Type the Following words 
3.This Fish This Fish (can be any words, but my macro I am attaching searches for "This")
4. Create and run the following Macro
5. You can comment and uncomment each Search attribute individually, and see each causes the same error.

Sub SearchFormatting

  Dim oSearch
  Dim SrchAttributes(0) as new com.sun.star.beans.PropertyValue

  oSearch = ThisComponent.createSearchDescriptor()

  oSearch.SearchString = "this"  
  'oSearch.ReplaceString = "That" 'Uncomment this to see that the Find is performing a replace.
  oSearch.ValueSearch = True ' True or False, the effect is the same.

  REM Set the CharRelief attribute to find
 SrchAttributes(0).Name = "CharRelief"
 SrchAttributes(0).Value = 0
  'NONE = 0
  'EMBOSSED = 1
 ' ENGRAVED = 2  Any of these values causes the error.
 
 ' SrchAttributes(0).Name = "CharRotation" 
  'SrchAttributes(0).Value = 0 'Any acceptable value causes the same error.
  
  ' SrchAttributes(0).Name = "CharScaleWidth" 
  'SrchAttributes(0).Value = 100 'Any acceptable value causes the same error.

  ' SrchAttributes(0).Name = "ParaVertAlignment" 
  'SrchAttributes(0).Value = 0 'Any acceptable value causes the same error.


  REM Set the attributes in the Search descriptor
  oSearch.SetSearchAttributes(SrchAttributes())
  
 ThisComponent.findAll(oSearch)
  'ThisComponent.findFirst(oSearch)'Both FindAll and FindFirst behave the same.
  
End Sub


Actual Results:
After running the above Macro all results matching "this" are erased, if I uncomment 'oSearch.ReplaceString, all results are replaced with the set replace string. 

Expected Results:
I would expect the Basic/Macro commands FindAll and FindFirst to return the Result as an Object and NOT modify the text.


Reproducible: Always


User Profile Reset: Yes

Additional Info:
Version: 7.3.4.2 (x64) / LibreOffice Community
Build ID: 728fec16bd5f605073805c3c9e7c4212a0120dc5
CPU threads: 2; OS: Windows 6.1 Service Pack 1 Build 7601; UI render: Skia/Raster; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: CL

  ' SrchAttributes(0).Name = ""WritingMode"" 
  'SrchAttributes(0).Value = 0 'Any acceptable value causes the same error.

also causes the same error when search individually, but not when combined, this may not be part of a bug?
Comment 1 Don 2023-01-30 00:57:31 UTC
Created attachment 185007 [details]
Test Document with Macro as described in Bug report.
Comment 2 Don 2023-01-30 19:09:15 UTC
The following  Hyphenation settings also cause the error.
"ParaIsHyphenation"
"ParaHyphenationNoCaps"
"ParaHyphenationMaxHyphens"
"ParaHyphenationMaxLeadingChars"
"ParaHyphenationMaxTrailingChars"

As well as the following Text Flow settings.
"ParaOrphans"
"ParaWidows"
Comment 3 Commit Notification 2023-02-01 06:50:04 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/2d9570523b16dd157eeee384040642e3c2e0ed05

tdf#153272: add some missing properties in SwSearchProperties

It will be available in 7.6.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 4 Don 2023-02-02 02:04:01 UTC
(In reply to Commit Notification from comment #3)
> Julien Nabet committed a patch related to this issue.
> It has been pushed to "master":
> 
> https://git.libreoffice.org/core/commit/
> 2d9570523b16dd157eeee384040642e3c2e0ed05
> 
> tdf#153272: add some missing properties in SwSearchProperties
> 
> It will be available in 7.6.0.
> 
> The patch should be included in the daily builds available at
> https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
> information about daily builds can be found at:
> https://wiki.documentfoundation.org/Testing_Daily_Builds
> 
> Affected users are encouraged to test the fix and report feedback.

Pardon me if this is not how I should report feedback, but in looking at the committed patch I do not see mention of the hyphenation and orphan/Widow settings listed, is this a separate issue? Or was my comment #2 not submitted in time? 
Thank you, 
Don
Comment 5 Commit Notification 2023-02-02 11:27:06 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "libreoffice-7-5":

https://git.libreoffice.org/core/commit/52216e9aad59c6c43b47f3d29d73bde9d11280d3

tdf#153272: add some missing properties in SwSearchProperties

It will be available in 7.5.1.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 6 Commit Notification 2023-02-03 10:55:37 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/52ebc632b3cfa122dcb178cf28d8dbc7c7c57007

Related tdf#153272: add some missing properties in SwSearchProperties

It will be available in 7.6.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 7 Julien Nabet 2023-02-03 10:56:53 UTC
For these:
"ParaIsHyphenation"
"ParaHyphenationNoCaps"
"ParaHyphenationMaxHyphens"
"ParaHyphenationMaxLeadingChars"
"ParaHyphenationMaxTrailingChars"

I asked for some help in https://gerrit.libreoffice.org/c/core/+/146435 but had no feedback yet.
Comment 8 Don 2023-02-05 02:49:27 UTC
(In reply to Julien Nabet from comment #7)
> For these:
> "ParaIsHyphenation"
> "ParaHyphenationNoCaps"
> "ParaHyphenationMaxHyphens"
> "ParaHyphenationMaxLeadingChars"
> "ParaHyphenationMaxTrailingChars"
> 
> I asked for some help in https://gerrit.libreoffice.org/c/core/+/146435 but
> had no feedback yet.

Thank you for your prompt replies and assistance Julien Nabet. I have tested the 7.5.1 daily build and can confirm that the errors with Char Relief, Rotation, Scale Width, and ParaVert Alignment has been corrected. I would assume that Orphan and Widow will be corrected when that patch is released. I tested Writing Mode and it produced the same error I mentioned, I tried combining it with other related settings as I did before and it still caused the disappearing problem non-the-less, although in testing it in the L.O. UI I can't quite figure out how to set it to search for it there anyway, so perhaps this is not a bug?? I'm not sure. 

As for the hyphenation I will keep an eye out for how that turns out. 

Considering that your patches have fixed the initial problems listed, should I be marking this bug as "fixed"? Or should I wait until the Hyphenation has been resolved, and until the ParaOrphan and Widow patch has been tested? 
Kind regards,
Don
Comment 9 Commit Notification 2023-02-06 13:06:03 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "libreoffice-7-5":

https://git.libreoffice.org/core/commit/53277b6d06e2b4bfef9e5d47329aabee77c15a18

Related tdf#153272: add some missing properties in SwSearchProperties

It will be available in 7.5.1.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.