Bug 116676 - Function insertTextPortion() of XTextPortionAppend Interface doesn't work
Summary: Function insertTextPortion() of XTextPortionAppend Interface doesn't work
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
5.4.6.2 release
Hardware: x86-64 (AMD64) All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Macro-UNOAPI
  Show dependency treegraph
 
Reported: 2018-03-28 09:16 UTC by Roland Baudin
Modified: 2023-07-05 07:48 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Simple document with a form that contains a rich text control (8.71 KB, application/vnd.oasis.opendocument.text)
2018-03-28 09:16 UTC, Roland Baudin
Details
Simple document with a form that contains a rich text control plus macro (10.07 KB, application/vnd.oasis.opendocument.text)
2018-04-03 15:32 UTC, Buovjaga
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Roland Baudin 2018-03-28 09:16:01 UTC
Created attachment 140932 [details]
Simple document with a form that contains a rich text control

The function insertTextPortion() of the XTextPortionAppend Interface doesn't work.

I attached a simple document that contains a form with a rich text control.

The following macro should first insert the unformatted text "Text", then append the formatted text "Append" (in Arial red) using apendTextPortion() and at last insert at the beginning the text "Insert" (in Arial red) using insertTextPortion().

While appendTextPortion() works as expected (text is appended with the right format), insertTextPortion() does not work: simply, nothing happens when it is called.

Here is the test macro:

Sub Test()

Dim oForm As Object, oCtrl as Object

' Get form and rich text control
oForm = thisComponent.DrawPage.Forms.getByName("Form1")
oCtrl = oForm.getByName("Text1")

' Append unformatted text => works
oCtrl.Text = "Text"

' Text properties
Dim aStyleProps(1) As New com.sun.star.beans.PropertyValue
aStyleProps(0).Name = "CharColor"
aStyleProps(0).Value = rgb( 255, 0, 0 )
aStyleProps(1).Name = "CharFontName"
aStyleProps(1).Value = "Arial"

' Append formatted text => works
oCtrl.appendTextPortion("Append", aStyleProps) 

' Insert formatted text at the start => does not work
Dim oTextCursor as Object
oTextCursor = oCtrl.createTextCursor()
oTextCursor.GotoStart(FALSE)
oCtrl.insertTextPortion("Insert", aStyleProps, oTextCursor) 

End Sub
Comment 1 Buovjaga 2018-04-03 15:32:46 UTC
Created attachment 141058 [details]
Simple document with a form that contains a rich text control plus macro
Comment 2 Buovjaga 2018-04-03 15:33:02 UTC
Repro.

Arch Linux 64-bit
Version: 6.1.0.0.alpha0+
Build ID: 6acda2a36c9025e0d3fe94d6ca8788ab60c3203e
CPU threads: 8; OS: Linux 4.15; UI render: default; VCL: kde4; 
Locale: fi-FI (fi_FI.UTF-8); Calc: group
Built on April 2nd 2018
Comment 3 QA Administrators 2019-04-04 03:04:13 UTC Comment hidden (obsolete)
Comment 4 himajin100000 2019-08-27 05:38:28 UTC Comment hidden (obsolete)
Comment 5 himajin100000 2019-08-27 05:39:03 UTC
oops, I mis-posted to the wrong bug report.
Comment 8 QA Administrators 2021-09-20 03:39:35 UTC Comment hidden (obsolete)
Comment 9 Roland Baudin 2023-05-18 15:31:07 UTC
The bug is still there in LibreOffice 7.5.3.2.

I checked the source code and found that in file editeng/source/uno/unotext.cxx, the method:

uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextBase::insertTextPortion(
        const OUString& /*rText*/,
        const uno::Sequence< beans::PropertyValue >& /*rCharAndParaProps*/,
        const uno::Reference< text::XTextRange>& /*rTextRange*/ )
{
    uno::Reference< text::XTextRange > xRet;
    return xRet;
}

doesn't do anything, it is a dummy method.

On the contrary, the method:

uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextBase::appendTextPortion(
        const OUString& rText,
        const uno::Sequence< beans::PropertyValue >& rCharAndParaProps )

is fully implemented.
Comment 10 Maxim Monastirsky 2023-07-05 07:48:15 UTC
Fixed by commit da8dead8e9282010893cbd12519e107baf03cd1a.