Mailing from database, how to insert new paragraph inside data

Hi,

I did mailing with Writer from database and some record have two or more paragraphs separated with LF and CR.
On postgresql database the exact symbol for this is E’\r\n’
Once inserted in the document, Writer does not convert the symbol as a new paragraph.
Visually the text goes down but it is not interpreted by Writer as start of a new paragraph.
I save the entire document as a multiple .odt files and check what is really inside.

There is no paragraph symbol but one strange character. The regular expression of it is \n (I can do search)
Graphically it look like the folded arrow seen on the return key.

What is the exact string or symbols used in Writer document to mark new paragraph ? Can it be expressed as unicode utf8 ?

Thanks

A Writer document is not “simply” a sequence of characters with some formatting directives added. Internally it is an ordered collection of objects in one or several flows. The main flow contains your discourse as a set of paragraphs.

Paragraphs are primary objects made of text, formatting, other object references (images, frames, equations, …) and links to “environment” like page definition. Therefore, there is no need to have special markers for end_of_paragraph because this “boundary” is implicit in the representation.

The problem here is your PostgeSQL database contains TEXT fields which need to be converted to Writer data. Through mail merge, you import character data without any formatting. You have chosen to identify paragraphs in your DB with CARRIAGE RETURN+LINE FEED pair. This is adequate for text-only data but will be interpreted differently by Writer.

CARRIAGE RETURN will be stripped and only LINE FEED is kept, causing a line break in the current paragraph. When you turn on View>Formatting Marks, this line break is shown as ↲ while a true paragraph mark is ¶.

You can replace line breaks by paragraph marks with Edit>Find & Replace in Regular expressions mode. Find \n and Replace \n.

Don’t be confused by the apparent no-change of this setting. \n have different interpretation when written in the find and replace fields because the command operates strictly inside a paragraph. Therefore, \n in Find is internal to the paragraph and can only be a line break. In Replace, it is interpreted as a request to insert a paragraph mark.

The Find & Replace is very helpful but is there any manner to do it fast or automatic without using the menu or the dialog box ?

Try ReplaceLineFeed.

Option Explicit

Sub ReplaceRegular(ByVal oDoc, ByVal searchString As String, _
                               ByVal replaceString As String)
  Dim oReplace
  oReplace = oDoc.createReplaceDescriptor()
  With oReplace
    .SearchString = searchString
    .ReplaceString = replaceString 
    .SearchRegularExpression=True
    .SearchAll=True
  End With   
  oDoc.replaceAll(oReplace)
End Sub

Sub ReplaceLineFeed()
  ReplaceRegular ThisComponent, "\R", "\n"
End Sub

Thanks for all