Bug 95340 - Search and replace macro with regular \n
Summary: Search and replace macro with regular \n
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
4.5.0.0.alpha0+ Master
Hardware: Other All
: medium minor
Assignee: Caolán McNamara
URL:
Whiteboard: target:5.3.0 target:5.2.1
Keywords: bibisected, bisected, regression
: 94953 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-10-26 20:14 UTC by goff@rg-rb.de
Modified: 2016-10-25 18:40 UTC (History)
7 users (show)

See Also:
Crash report or crash signature:


Attachments
Buggy macro (11.94 KB, application/vnd.oasis.opendocument.text)
2015-10-30 17:37 UTC, goff@rg-rb.de
Details
95340 (13.66 KB, application/vnd.oasis.opendocument.text)
2015-10-30 21:54 UTC, goff@rg-rb.de
Details

Note You need to log in before you can comment on or make changes to this bug.
Description goff@rg-rb.de 2015-10-26 20:14:12 UTC
Search and replace works not correct if executed in a macro and "\n" is in replace field. Lets say, we have macro for Writer:


sub PDF2TXT

	Dim oDocument			As Object
	Dim oSearch			As Object
	Dim oReplace			As Object
	Dim oResult			As Object

	oDocument = ThisComponent
	
	oReplace = oDocument.createReplaceDescriptor
	oReplace.searchAll=True 
	oReplace.SearchRegularExpression = true
	oReplace.SearchCaseSensitive = false
	oReplace.SearchWords = false
		
	oReplace.SearchString = "########"
	oReplace.ReplaceString = "\n"
	
	oDocument.replaceAll(oReplace)

end sub

Expected: all ######## are replaced with new paragraph
Reality: only first or 2 firsts character strings are replaced.

Manual "Search and replace" works fine.

This bug is specific for 5.x.x, older versions worked fine.
Comment 1 goff@rg-rb.de 2015-10-26 21:16:14 UTC
UPDATE - version 4.0.2 worked fine = this bug is uppeared between 4.0.2 and 5.0.2
Comment 2 raal 2015-10-28 13:24:40 UTC
(In reply to goff@rg-rb.de from comment #1)
> UPDATE - version 4.0.2 worked fine = this bug is uppeared between 4.0.2 and
> 5.0.2

setting as regression. Please attach test file for easy testing, thanks
Comment 3 goff@rg-rb.de 2015-10-30 17:37:43 UTC
Created attachment 120117 [details]
Buggy macro
Comment 4 goff@rg-rb.de 2015-10-30 21:54:56 UTC
Created attachment 120125 [details]
95340

Corrected file for testing bug 95340
Comment 5 Buovjaga 2015-11-09 11:01:39 UTC
(In reply to goff@rg-rb.de from comment #4)
> Created attachment 120125 [details]
> 95340
> 
> Corrected file for testing bug 95340

Repro with 5.0.

5.1 says:
BASIC runtime error.
Property or method not found: searchAll.

Maybe it was removed??

Win 7 Pro 64-bit, Version: 5.0.3.2 (x64)
Build ID: e5f16313668ac592c1bfb310f4390624e3dbfb75
Locale: fi-FI (fi_FI)

Version: 5.1.0.0.alpha1+
Build ID: 6da681442b17c723f9408a806e8d2367441ad65a
TinderBox: Win-x86@62-merge-TDF, Branch:MASTER, Time: 2015-11-07_23:13:46
Locale: fi-FI (fi_FI)
Comment 6 raal 2015-11-10 09:51:17 UTC
bibisecting of issue : 
5.1 says:
BASIC runtime error.
Property or method not found: searchAll.

This seems to have begun at the below commit.
Adding Cc: to Matthew J. Francis; Could you possibly take a look at this one? Thanks
 bc0b2085d043ff9bb2d891b55e4a7f45a9dd4bf7 is the first bad commit
commit bc0b2085d043ff9bb2d891b55e4a7f45a9dd4bf7
Author: Norbert Thiebaud <nthiebaud@gmail.com>
Date:   Sun Jul 26 14:49:20 2015 -0700
    source 61b1697069c50ff72339d4592add42ab72b03243
    source 61b1697069c50ff72339d4592add42ab72b03243

	author	Matthew J. Francis <mjay.francis@gmail.com>	2015-07-06 00:09:24 (GMT)
committer	Stephan Bergmann <sbergman@redhat.com>	2015-07-08 14:51:54 (GMT)
commit 61b1697069c50ff72339d4592add42ab72b03243 (patch)
Reduce the amount of up front work in performing introspection

bibisect-win32-5.1
$ git bisect log
# bad: [7af0dacdc70e7e8bd0785ab0be6e6ca64b64d08d] source 8bde421ccec9c10fe1382ad68485852889dd4c74
# good: [c1efd324c6ad448ac9edb030dc9738b9e6899e4d] source ab465b90f6c6da5595393a0ba73f33a1e71a2b65
git bisect start '7af0dacdc70e7e8bd0785ab0be6e6ca64b64d08d' 'c1efd324c6ad448ac9edb030dc9738b9e6899e4d'
# bad: [3f6a85ce123f4e0c065f1c28b02f66dc7734cc04] source 647b5aecd4c3facc302df33386451dda732aab98
git bisect bad 3f6a85ce123f4e0c065f1c28b02f66dc7734cc04
# bad: [3f6a85ce123f4e0c065f1c28b02f66dc7734cc04] source 647b5aecd4c3facc302df33386451dda732aab98
git bisect bad 3f6a85ce123f4e0c065f1c28b02f66dc7734cc04
# good: [c1575e5261af5b8dbdf5740a9bc4e6c7a1ba74d8] source cfbbb3ca5d0d7bc479e219e17aa2919196664118
git bisect good c1575e5261af5b8dbdf5740a9bc4e6c7a1ba74d8
# good: [c1575e5261af5b8dbdf5740a9bc4e6c7a1ba74d8] source cfbbb3ca5d0d7bc479e219e17aa2919196664118
git bisect good c1575e5261af5b8dbdf5740a9bc4e6c7a1ba74d8
# bad: [db6594849c23b0cbdb542f14457610df1e580f11] source 92f32585708a251526492f1eb576744bee8d5a5f
git bisect bad db6594849c23b0cbdb542f14457610df1e580f11
# good: [84744088e5b698f0c4697a5cf460370406653074] source 36a77b748a0b1d35ce72b2e14d1daa158d5f7c4b
git bisect good 84744088e5b698f0c4697a5cf460370406653074
# bad: [028b886da9c94482e056adcdaa992a6fa2859a00] source 07ebc7771a8c9d8483e1dc7eac408f568434b7b5
git bisect bad 028b886da9c94482e056adcdaa992a6fa2859a00
# bad: [a55f85d6799ce51b0f3b177eb653622a341793b4] source 97df2dee8ea4f33f4efb7467cfeec2d8954c006c
git bisect bad a55f85d6799ce51b0f3b177eb653622a341793b4
# good: [696319a18045bd52ca416f806696ce76b56368a6] source 4c9d7772bd76c30ddbfb7e0b3460aabb9529cfde
git bisect good 696319a18045bd52ca416f806696ce76b56368a6
# good: [4db91de635d26903dcb7450dece7330563438fa0] source 5c10e8cd0eedefc2dcc905154c4daa142561aef3
git bisect good 4db91de635d26903dcb7450dece7330563438fa0
# good: [57f95b66c1608d57583558d48c922e9f0375f869] source 6793eaa4fa77292b23e9b86221e598f438d45b8e
git bisect good 57f95b66c1608d57583558d48c922e9f0375f869
# bad: [3c110371fe2dabc43663c87a184dac09053b74f5] source cc43153f466135b959605add37ccd9443852c185
git bisect bad 3c110371fe2dabc43663c87a184dac09053b74f5
# bad: [bc0b2085d043ff9bb2d891b55e4a7f45a9dd4bf7] source 61b1697069c50ff72339d4592add42ab72b03243
git bisect bad bc0b2085d043ff9bb2d891b55e4a7f45a9dd4bf7
# good: [1f62c5a5e84bf22c1e4aec2448ab73a9c0dfd634] source b3e645cde951906d883f015d342f85fc0eedb2ec
git bisect good 1f62c5a5e84bf22c1e4aec2448ab73a9c0dfd634
# first bad commit: [bc0b2085d043ff9bb2d891b55e4a7f45a9dd4bf7] source 61b1697069c50ff72339d4592add42ab72b03243
Comment 7 raal 2015-11-10 11:15:29 UTC
bibisect-win32-5.0, oldest version contains bug too.
git checkout oldest: Version: 4.5.0.0.alpha0+
Build ID: 57d6b92b69a31260dea0d84fcd1fc5866ada7adb
Comment 8 raal 2015-11-10 17:38:04 UTC
bibisecting issue: only first or 2 firsts character strings are replaced.

This seems to have begun at the below commit.
Adding Cc: to Bjoern Michaelsen ; Could you possibly take a look at this one?
Thanks
 673d38fff54dec0a1131ac13dbc10212604bc265 is the first bad commit
commit 673d38fff54dec0a1131ac13dbc10212604bc265
Author: Matthew Francis <mjay.francis@gmail.com>
Date:   Sat Mar 14 23:48:57 2015 +0800

    source-hash-f3974d020b8c066dcb08a54ad94740d5131c86f9
    
    commit f3974d020b8c066dcb08a54ad94740d5131c86f9
    Author:     Bjoern Michaelsen <bjoern.michaelsen@canonical.com>
    AuthorDate: Fri Jul 25 00:24:08 2014 +0200
    Commit:     Bjoern Michaelsen <bjoern.michaelsen@canonical.com>
    CommitDate: Fri Jul 25 09:47:52 2014 +0200
    
        simplify ChkPaM some more
    
        Change-Id: I499f76252d145fc3a3afd2e3646ef81e8055e327

bibisect-44max$ git bisect log
# bad: [cf6ea17155fabb2a120ba07c150735591ac861d7] source-hash-3f94c9e9ddfd807b449f3bb9b232cf2041fa12d2
# good: [fc71ac001f16209654d15ef8c1c4018aa55769f5] source-hash-c15927f20d4727c3b8de68497b6949e72f9e6e9e
git bisect start 'latest' 'oldest'
# bad: [8cf60cc706948588e2f33a6d98b7c55d454e362a] source-hash-f340f0454627939f1830826fb5cc53a90e6c62a4
git bisect bad 8cf60cc706948588e2f33a6d98b7c55d454e362a
# good: [d9885f526fc7a09cc8f9f8ee643af1b966be24bb] source-hash-d1465c64c6f64ad8dd25e40cdc69649b24b305ea
git bisect good d9885f526fc7a09cc8f9f8ee643af1b966be24bb
# bad: [c779cf7967f4d14c5e649a5c696b07279d550efd] source-hash-e9c5022580f14c0ca97503f8b3cc56b530fff174
git bisect bad c779cf7967f4d14c5e649a5c696b07279d550efd
# good: [030e0477638f9d9110ad62f88fd4b881521e0541] source-hash-1a6e47e3fda10e6d220b67d766ec6fbdfd852b80
git bisect good 030e0477638f9d9110ad62f88fd4b881521e0541
# good: [c9e7f255b30a0410226b2074702aeba9b49dce13] source-hash-2d5a7c36ee9ae7ff39d8415f81fb911ff822548e
git bisect good c9e7f255b30a0410226b2074702aeba9b49dce13
# bad: [0996e94321008e9f1857c299efad9dc3bc6e5ff2] source-hash-6c1f2ea2aa11b2c8fd42b455c7c452194ed2c1e7
git bisect bad 0996e94321008e9f1857c299efad9dc3bc6e5ff2
# good: [c69835b63d379747e58c9d6315dbf32a09e842ef] source-hash-d5fb4b731938c22fcf9c5e3280da8f722b5492e4
git bisect good c69835b63d379747e58c9d6315dbf32a09e842ef
# good: [90012cb7ba832730701e29655d352a5929a14161] source-hash-81b594afa7162552fc2489ba0c7e1e8b5addb4f2
git bisect good 90012cb7ba832730701e29655d352a5929a14161
# good: [5bd8a7898e84515432797814189a8fdec6967587] source-hash-d60cec0e60c5c0880f8098d39443c391abed80b2
git bisect good 5bd8a7898e84515432797814189a8fdec6967587
# good: [eabdd8aa8d46d815061807118b572b8b5a9d655e] source-hash-5e16ed096e636def009dd7db18cd96d304b14b69
git bisect good eabdd8aa8d46d815061807118b572b8b5a9d655e
# good: [76671c243dda30b57fb03b37ef6b67b66c739234] source-hash-41c5d4c4f83b09f2fedb53bb8e63caaf9a210986
git bisect good 76671c243dda30b57fb03b37ef6b67b66c739234
# good: [291aee12c85f59e082e6f6d6926e4de65ef92235] source-hash-4a1a94dff6a76d70ee72c6c840a24953eca0a9f0
git bisect good 291aee12c85f59e082e6f6d6926e4de65ef92235
# bad: [673d38fff54dec0a1131ac13dbc10212604bc265] source-hash-f3974d020b8c066dcb08a54ad94740d5131c86f9
git bisect bad 673d38fff54dec0a1131ac13dbc10212604bc265
# good: [e4edd8999bdb0c33d69ac4478f14a7d911e623ce] source-hash-bb67dc2752cc37a636fc851ba5b29e6cf0236362
git bisect good e4edd8999bdb0c33d69ac4478f14a7d911e623ce
# first bad commit: [673d38fff54dec0a1131ac13dbc10212604bc265] source-hash-f3974d020b8c066dcb08a54ad94740d5131c86f9
Comment 9 Robinson Tryon (qubit) 2015-12-13 11:14:23 UTC Comment hidden (obsolete)
Comment 10 Commit Notification 2016-07-21 14:48:42 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=a58e46482c2af06ee9be26313db3513f906d6c0b

Resolves: tdf#95340 orig lcl_ChkUnoCrsrPaM had reversed 'set' to lcl_ChkPaM

It will be available in 5.3.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 11 Caolán McNamara 2016-07-21 14:53:53 UTC
I think the original refactor missed that the args to the uno variants were a little different to the non-uno variants. If I re-refactor it then this example works again.
Comment 12 Caolán McNamara 2016-07-21 14:56:34 UTC
*** Bug 94953 has been marked as a duplicate of this bug. ***
Comment 13 Commit Notification 2016-07-25 07:29:09 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "libreoffice-5-2":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=3583db525c118a4a2adea843698c9619cfd7f221&h=libreoffice-5-2

Resolves: tdf#95340 orig lcl_ChkUnoCrsrPaM had reversed 'set' to lcl_ChkPaM

It will be available in 5.2.1.

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

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