Issue 87092 - Find and Replace with formatting inserts unwanted "x"
Summary: Find and Replace with formatting inserts unwanted "x"
Status: CLOSED FIXED
Alias: None
Product: Writer
Classification: Application
Component: code (show other issues)
Version: OOo 2.4 RC5
Hardware: All Windows XP
: P3 Trivial (vote)
Target Milestone: ---
Assignee: stefan.baltzer
QA Contact: issues@sw
URL:
Keywords: regression
: 87642 88726 (view as issue list)
Depends on:
Blocks:
 
Reported: 2008-03-16 16:25 UTC by ingenstans
Modified: 2013-08-07 14:43 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description ingenstans 2008-03-16 16:25:15 UTC
I think this is a regression; I have certainly noticed it only in the last
couple of months.

If I use a macro to replace all italic formatted text in a document with plain
text surrounded by the equivalent html markup, a spurious "x" is added at the
end of the replacement string. 

Steps to repeat:

(1) write a document containing two or more stretches of italicised text. 
(2) run the following macro


Expected result: the italic text ranges are converted to plain text and given
tags at each end that say "<em> and "</em>"

Actual result: the italic text ranges are converted to plain text and given tags
at each end that say "<em> and "x</em>"
Note the extra, spurious "x"

The macro that does this:

Sub ital_to_HTML_Tags
dim oDoc,oRD,numfound
dim italicargs(0)as new com.sun.star.beans.PropertyValue
dim normalargs(0)as new com.sun.star.beans.PropertyValue
	oDoc=thiscomponent
	oRD=oDoc.createReplaceDescriptor()
	italicargs(0).Name="CharPosture"
	italicargs(0).Value=com.sun.star.awt.FontSlant.ITALIC
	oRD.ValueSearch=True
	oRD.SearchWords=True
	normalargs(0).Name="CharPosture"
	normalargs(0).Value=com.sun.star.awt.FontSlant.NONE
	oRD.setSearchAttributes(italicargs())
	oRD.setReplaceAttributes(normalargs())
	oRD.setSearchString(".+")
	oRD.setReplaceString("<em>&</em>")
	oRD.SearchRegularExpression=True
	oRD.SearchStyles=False
	numfound=oDoc.ReplaceAll(oRD)
'	msgbox(numfound)
end Sub

An equivalent macro to replace bold formatting with <b> tags has the same bug.
Comment 1 michael.ruess 2008-03-17 11:10:47 UTC
Reassigned to SBA.
Comment 2 jurf 2008-03-25 20:07:47 UTC
I came across the same problem independently of reporter. Can confirm bug is
present in beta 4.0 rc2 and rc6; likely other rc's too. Bug not present in 2.3.1
or earlier. Looks like some new feature or fix has created this problem.

Bug can be isolated to oDoc.ReplaceAll. Tested with Italic and Bold.
Comment 3 ingenstans 2008-03-26 20:29:27 UTC
keyword added after confirmation from jurf
Comment 4 jurf 2008-04-21 01:25:56 UTC
Bug also confirmed on OOo 3.0 beta m9 (OOo-Dev_DEV300_m9_Win32Intel). This is a
definite regression introduced in the 2.4 beta series. Unfortunately,
oDoc.ReplaceAll is a vital component of macros I use to clean up formatting
(e.g. in OCR output); as such, this issue is a showstopper as it prevents me
moving beyond OOo 2.3.
Comment 5 jurf 2008-04-28 23:52:52 UTC
Urk, it's not just macros: I also get stray "x"s using the "Find & Replace" UI
(OOo-dev 3.0). To reproduce, paste in a bunch of paste, mark part of it bold,
and an overlapping section as italic. eg.

Gimme some x's: [b]with luck following here [i]and here[b] - see?[/i] Rats.

(don't copy the tags - they're only there to suggest which bits you turn to bold
and which to italic)

The "Find & Replace" dialog settings are these:
Search for: .+
Format: bold
Replace with: [b]&[/b]
Regular Expressions
-> Replace All

Ouch. Looks like the bug affects code that splits the tags to avoid overlaps.

Workaround needs a macro: before running a search/replace involving formatting,
protect your x's by switching them to some unique tag. You've run your replace
routine, delete all the x's, and revert the temporary tags back to real x's.
Comment 6 andreas.martens 2008-05-27 09:33:00 UTC
To reproduce this there is no need for overlapping attributes, just a dummy text
with one bold word and you will get an additional "x". Even I think there is a
bug somewhere in an involved external library, I can easily fix this in my code.

Fixed in CWS sw30bf05
findtxt.cxx
Comment 7 stefan.baltzer 2008-05-27 11:37:29 UTC
SBA: Adjusted summary. Was OK in OOo 2.3.1, broken in OOo 2.4.
Comment 8 stefan.baltzer 2008-05-27 13:52:01 UTC
*** Issue 83938 has been marked as a duplicate of this issue. ***
Comment 9 stefan.baltzer 2008-05-27 13:56:28 UTC
*** Issue 87642 has been marked as a duplicate of this issue. ***
Comment 10 stefan.baltzer 2008-05-27 14:08:00 UTC
*** Issue 88726 has been marked as a duplicate of this issue. ***
Comment 11 Frank Schönheit 2008-05-28 06:55:06 UTC
fix copied to CWS dba241e, which targets to 2.4.1
Comment 12 Frank Schönheit 2008-05-28 07:00:29 UTC
fs->sba: please verify in CWS dba241e
Comment 13 andreas.martens 2008-05-28 07:58:24 UTC
ama->sba:
Checked in dba241e => Ready for QA.

But don't close this issue afterwards because you have to verify it in sw30bf05
(DEV300) again.
Comment 14 stefan.baltzer 2008-05-28 09:55:16 UTC
Verified in CWS dba241e.
Comment 15 stefan.baltzer 2008-05-30 19:12:48 UTC
SBA: Re-Verified in OOH680_m17 (=> OK in OOo 2.4.1)
Not closing now, see AMAs comment above.
Comment 16 Mechtilde 2008-05-31 20:46:29 UTC
.
Comment 17 Mechtilde 2008-07-19 20:19:48 UTC
@ andrewb

Can you verify it in last master?
Comment 18 stefan.baltzer 2008-09-24 15:33:51 UTC
SBA: OK in Build OOO300_m7 (OOo 3.0 RC2).
Closed.