https://bugs.documentfoundation.org/show_bug.cgi?id=89920
Bug ID: 89920
Summary: inserting line break to cell from macro
Product: LibreOffice
Version: unspecified
Hardware: Other
OS: All
Status: UNCONFIRMED
Severity: normal
Priority: medium
Component: Calc
Assignee: [email protected]
Reporter: [email protected]
Consider the following macro:
sub Main
my_cell = ThisComponent.Sheets(0).getCellByPosition(0,0)
my_cell.String = "aa bb" + chr(10) + "cc dd"
end sub
It will write to A1 cell on the first sheet:
aa bb
cc dd
It will be saved to ODS as:
<table:table-cell office:value-type="string"
calcext:value-type="string">
<text:p>aa bb</text:p>
<text:p>cc dd</text:p>
</table:table-cell>
It is good. However, let's have "aa bb cc dd" in cell A1. Now we want to
replace consecutive spaces to line breaks. We cannot do this from UI, so let's
use a macro.
sub Main
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
dim args2(17) as new com.sun.star.beans.PropertyValue
args2(0).Name = "SearchItem.StyleFamily"
args2(0).Value = 2
args2(1).Name = "SearchItem.CellType"
args2(1).Value = 0
args2(2).Name = "SearchItem.RowDirection"
args2(2).Value = true
args2(3).Name = "SearchItem.AllTables"
args2(3).Value = false
args2(4).Name = "SearchItem.Backward"
args2(4).Value = false
args2(5).Name = "SearchItem.Pattern"
args2(5).Value = false
args2(6).Name = "SearchItem.Content"
args2(6).Value = false
args2(7).Name = "SearchItem.AsianOptions"
args2(7).Value = false
args2(8).Name = "SearchItem.AlgorithmType"
args2(8).Value = 1
args2(9).Name = "SearchItem.SearchFlags"
args2(9).Value = 65536
args2(10).Name = "SearchItem.SearchString"
args2(10).Value = " {2,}"
args2(11).Name = "SearchItem.ReplaceString"
args2(11).Value = chr(10)
args2(12).Name = "SearchItem.Locale"
args2(12).Value = 255
args2(13).Name = "SearchItem.ChangedChars"
args2(13).Value = 2
args2(14).Name = "SearchItem.DeletedChars"
args2(14).Value = 2
args2(15).Name = "SearchItem.InsertedChars"
args2(15).Value = 2
args2(16).Name = "SearchItem.TransliterateFlags"
args2(16).Value = 1280
args2(17).Name = "SearchItem.Command"
args2(17).Value = 3
dispatcher.executeDispatch(document, ".uno:ExecuteSearch", "", 0, args2())
end sub
Please note, that the replacement text is the same chr(10) as in the first
macro. But in A1 we will see: "aa bbcc dd". When we save it to ODS, we have
this xml in the file:
<table:table-cell office:value-type="string"
calcext:value-type="string">
<text:p>aa bb
<text:line-break/>
cc dd</text:p>
</table:table-cell>
So, we don't have two <text:p> elements, but the <text:line-break/> between the
two lines. Unfortunately when LibreOffice reads this back, the line break
disappears forever. Interestingly saving to XLS and reload from that XLS
preserves the line break.
Expected behaviour: if chr(10) means line break in the cell, then it should
work in case of search and replace, too.
--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Libreoffice-bugs mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs