Insert > Horizontal Line doesnt actually insert a horizontal line, but instead changes the paragraph to the 'Horizontal Line' paragraph style, which if done on a line/paragraph with text, it will not have the desired result.
So the new horizontal line uno command should insert 2 paragraph breaks at the current position of the cursor (without triggering any autocorrect triggers) and then move the cursor up once, then assign the 'Horizontal Line' paragraph style, and finally move the cursor left once.
Once the uno command is create it would replace .uno:StyleApply?Style:string=Horizontal Line&FamilyName:string=ParagraphStyles entry in writer's menubar.xml.
Do you expect a drawing object, a line with zero height, anchored at the paragraph, not interactive or at least secured against unintentional movements, probably adding space itself?
The border solution is always perfectly placed and sized, easy to modify by users, and also autotext'ed when entering ----------------.
Regina: Does ODF have a horizontal line object equivalent to OOXML's horizontal line (bug 97648), which unfortunately we are currently converting into a drawing object that wont adapt to changes in the page's size/margins.
ODF has no special element for a horizontal line.
The horizontal line is a picture-element with a rectangle as content anchored as character in Word. So the import as rectangular shape is correct. LibreOffice misses the implementation of the here needed attribute "style:rel-width" of the <style:graphic-properties> element.
Bug 45884 is related.
(In reply to Regina Henschel from comment #3)
> ODF has no special element for a horizontal line.
> The horizontal line is a picture-element with a rectangle as content
> anchored as character in Word.
Well for correct interopability with OOXML and other document formats, ODF will need something to identify the difference between a shape and a horizontal line, like how OOXML has it. OOXML uses the o:hr, o:hrstd, o:hrnoshade, o:hrpct, o:hralign attributes of the <v:rect> tag to represent this difference.
> So the import as rectangular shape is correct.
I believe it is incorrect to import it as a rectangular shape with a fill color and an undefined border line, but instead it should be imported as a defined line shape, but with the ability to extend its height similar to a rectangle shape. This will allow correct interopability with other document formats where you can define the line style, which isnt possible with a rectangular shape.