Bug 157141 - Text portion for content control gives empty string
Summary: Text portion for content control gives empty string
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium minor
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: DOCX-Content_Control
  Show dependency treegraph
 
Reported: 2023-09-07 16:55 UTC by Mike Kaganski
Modified: 2023-09-26 06:02 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Kaganski 2023-09-07 16:55:43 UTC
Open attachment 189413 [details], and use this code:

sub TestContentControlImportedObjects
  paragraphs = thisComponent.getText().createEnumeration()
  para1 = paragraphs.nextElement()
  runs1 = para1.createEnumeration()
  run1 = runs1.nextElement()
  para2 = paragraphs.nextElement()
  runs2 = para2.createEnumeration()
  run2 = runs2.nextElement()

  MsgBox run1.getString()
  MsgBox run2.getString()
  MsgBox run2.ContentControl.getString()
end sub

The document has two paragraphs, each having a content control with a placeholder text. Because the first one is a block control (which content includes the respective paragraph), and the second is an inline control (contained in the paragraph, and the content includes only a run), these two are imported differently (as of 2023-09-07): the first one as a field, and the second one as a content control.

The three MsgBox calls in the end of the code are expected to show the same "Click or tap here to enter text." string. However, the second call showing "run2.getString()" produces an empty message.

This happens because lcl_CreateContentControlPortion in sw/source/core/unocore/unoportenum.cxx is called with pUnoCursor pointing to the end of the paragraph. Looks like it needs to take into account the values of rAttr (and respective SwContentControl), and pPortions, which may contain the range that should become the actual cursor.
Comment 1 Buovjaga 2023-09-26 06:02:56 UTC
Repro

Arch Linux 64-bit, X11
Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 5e9c8d21874eea8cb5adf2ecab1905295af2308f
CPU threads: 8; OS: Linux 6.5; UI render: default; VCL: kf5 (cairo+xcb)
Locale: fi-FI (fi_FI.UTF-8); UI: en-US
Calc: threaded
Built on 26 September 2023