Apache OpenOffice (AOO) Bugzilla – Issue 23552
setString followed by setPropertyValue produces redundant formatting tags
Last modified: 2013-02-24 21:07:04 UTC
I'm developing a text converter which searches for strings with specific formatting and replaces them with other strings having different formatting. This program is crucial for me. But, since searching for formatted text in OOo is broken (see issue 10569) and nobody plans to fix this issue, I used the following algorithm as a workaround: first, we search for a string without formatting, then test formmating for each of all found text ranges, and, if it matches, change both the string an the formatting. Of course, this works too slow, but there is another problem: when I use XTextRange:setString in combination with setPropertyValue (), the text range always gets enclosed in its own pair of formatting tags, even if the text around it has the same formatting. So the xml code may look as follows: <text:span text:style-name="T1">Thi</text:span><text:span text:style-name="T1">s</text:span><text:span text:style-name="T1"> i</text:span><text:span text:style-name="T1">s</text:span><text:span text:style-name="T1"> j</text:span> Of course, this kind of formatting makes the whole document hardly usable. Previously I could remove this redundant formatting tags using one more replacement operation with empty searchString and replaceString and identical SearchAttributes and ReplaceAttributes. This worked until 1.1 RC4, but doesn't work now. So, simply there is no workaround any more, no way to implement the functionality I need! Of course I'd like prefer fixing issue 10569, but, if it is so difficult, is it possible a least prevent OOo from generating redundant formatting tags? The attached documents shows the problem. It contains a macro ("TestSearchReplace") which searches for characters formatted with Times New Roman, and replaces them with the same characters, but in Arial. To reproduce the problem: -- run the macro on this (or any other) document; -- save the document to another location, unzip it at look at content.xml. It should look as in the sample above.
Created attachment 11944 [details] A document containing a Basic macro which demonstrates the problem
forwarding to responsible developer
TL->FME: Since the same problem occurs in the UI, can you please take care of this?
FME->MRU: Could you please check this issue and choose a target?
MRU->SBA: This deals with Find&Replace.
set target not determined
SBA: Target set to "Office Later".