Issue 73247 - Basic: crash when looking at a TextSection
Summary: Basic: crash when looking at a TextSection
Status: CLOSED FIXED
Alias: None
Product: Writer
Classification: Application
Component: programming (show other issues)
Version: OOo 2.1
Hardware: All All
: P2 Trivial (vote)
Target Milestone: ---
Assignee: joerg.skottke
QA Contact: issues@sw
URL:
Keywords:
Depends on:
Blocks: 72764
  Show dependency tree
 
Reported: 2007-01-08 12:53 UTC by allart
Modified: 2013-08-07 14:43 UTC (History)
6 users (show)

See Also:
Issue Type: PATCH
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
A macro creating a TextSection (65.45 KB, application/vnd.sun.xml.writer)
2007-01-08 12:55 UTC, allart
no flags Details
Illustrating screenshot (32.90 KB, image/gif)
2007-01-08 15:38 UTC, kpalagin
no flags Details
patch file (1.13 KB, text/plain)
2008-05-15 08:43 UTC, jian.li
no flags Details
patch file (1.16 KB, text/plain)
2008-05-21 12:43 UTC, jian.li
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description allart 2007-01-08 12:53:46 UTC
Happy new year at all of you.

In the basic framework, create a macro which creates a textsection.
With the debugger, try to visit the content of the textsection.
OOo crashes.

Open the attached document, and edit the Module1/Main macro.
Put a breakpoint on the MsgBox statement.
try to look at "aSection".

I'm using OOo 2.1 (680m6) on Linux.

Best Reagard.
Comment 1 allart 2007-01-08 12:55:10 UTC
Created attachment 41996 [details]
A macro creating a TextSection
Comment 2 michael.ruess 2007-01-08 13:33:09 UTC
Reassigned to JSK.
Comment 3 kpalagin 2007-01-08 15:37:10 UTC
Confirming with OO 2.1 on both WinXP and Suse 10.2. To reproduce
1. Open attached file, enabling macros.
2. Go to OO basic, set breakpoint, add watch for "aSection".
3. Click "Step into" (see attached screenshot), then "Run BASIC", then 
click '+' sign next to "aSection" - OO crashes.
Comment 4 kpalagin 2007-01-08 15:38:45 UTC
Created attachment 42012 [details]
Illustrating screenshot
Comment 5 bmarcelly 2007-01-08 20:28:22 UTC
This problem already exists with Win XP on 2.0.4 and 1.1.5.

Crash does not appear after text section is inserted:

aSection = thisComponent.createInstance("com.sun.star.text.TextSection")

dim curs as object
curs = thisComponent.Text.createTextCursor
curs.gotoEnd(False)
thisComponent.Text.insertTextContent(curs, aSection, False)

MsgBox("Please look at the TextSection")
Comment 6 joerg.skottke 2007-01-09 07:27:23 UTC
Nice report with fancy screenshot. Thanks!
Forwarding to AB, set target 2.2 and raise prio to 2 (crash justifies for this)
Comment 7 bmarcelly 2007-01-09 09:08:04 UTC
Crash is produced by reading properties StartRedLine or EndRedLine.

aSection = thisComponent.createInstance("com.sun.star.text.TextSection")
dim foo
foo = aSection.StartRedLine   ' will crash
Comment 8 ab 2007-01-09 10:27:28 UTC
ab->fme: As discussed to you
Comment 9 frank.meies 2007-01-09 11:20:39 UTC
FME: Changed target to 2.x.
Comment 10 frank.meies 2008-01-10 11:38:51 UTC
Cannot be fixed until code freeze => target 3.0
Comment 11 frank.meies 2008-04-22 12:52:16 UTC
.
Comment 12 allart 2008-04-22 14:42:03 UTC
May be you can close this issue.

I can't reproduce it this OOo 2.4

Regards,

Ph.
Comment 13 jian.li 2008-05-15 08:41:15 UTC
lijian->fme:
This issue still exists in OpenOffice.org 3.0(DEV300_M5).
Here is my patch for this issue. Please have a look.
The main cause is references to null pointers.
Comment 14 jian.li 2008-05-15 08:43:52 UTC
Created attachment 53662 [details]
patch file
Comment 15 frank.meies 2008-05-16 10:31:25 UTC
fme->lijian: Have a look at this basic code:

Sub Main

curs = thisComponent.Text.createTextCursor

curs.gotoEnd(False)



' Table:

aTable = thisComponent.createInstance("com.sun.star.text.TextTable")

foo = aTable.StartRedLine ' => exception

thisComponent.Text.insertTextContent(curs, aSection, False)

foo = aTable.StartRedLine ' => ok



' Section:

aSection = thisComponent.createInstance("com.sun.star.text.TextSection")

foo = aSection.StartRedLine ' => crash

thisComponent.Text.insertTextContent(curs, aSection, False)

foo = aSection.StartRedLine ' => ok

End Sub


I think the way it works with tables is correct, an exception is thrown if the
property could not be retrieved (because the object has not been inserted yet).
Please have a look at unotbl.cxx to see how this works for tables.
Comment 16 jian.li 2008-05-21 12:40:53 UTC
lijian->fme:
Please have a look. But I am not sure.
Actually I don't make the conditions to throw exceptions for uno table clear.
Comment 17 jian.li 2008-05-21 12:43:14 UTC
Created attachment 53817 [details]
patch file
Comment 18 frank.meies 2008-05-21 13:46:30 UTC
fme->lijian: I had a second look at the code in unosect.cxx and unotbl.cxx. If a
new table or section is created, it is only in a 'descriptor' state. You can
set/get a couple of properties which are collected in
SwTextSectionProperties_Impl or aTableDescPropertyMap_Impl. Once the section or
table is inserted into the document (attachToRange), these properties are passed
to the Writer core object (which is created inside attachToRange). So what do we
expect if we have a not-yet-attached table (or section) and we ask for a
property which has not been set or which is not allowed to be set in descrptor
mode? For tables, an exception is thrown. I think this should happen for
sections as well. I'll discuss this with OS, who knows this code pretty well.
Please stay tuned...
Comment 19 frank.meies 2008-05-22 09:01:22 UTC
fme->lijian: I discussed this with OS. Right now, a not-yet-attached table
throws an exception when calling getPropertyValue() for a property that either
has not been set yet or a property that cannot be set (like the StartRedLine
property). A not-yet-attached section simply returns a default value in this
case. Throwing an exception when accessing StartRedLine would be somewhat
inconsistent with the   behavior when accessing e.g., the IsProtected flag of
the section (here we do not throw an exception but return the default value).
Not throwing an exception when accessing StartRedLine would be somewhat
inconsistent with the behavior of a not-yet-attached table when accessing
StartRedLine. So we have to choose and OS and I agreed upon not throwing an
exception but to simply catch the 0-pointer as you did in your first patch. I'll
integrate your patch and we consider this issue 'fixed'. Thank you for your work
on this.
Comment 20 frank.meies 2008-05-22 09:08:02 UTC
Fixed in cws fmepatches02, unosect.cxx.
Comment 21 jian.li 2008-05-22 09:29:16 UTC
lijian->fme:
Thank you for your help.
Comment 22 frank.meies 2008-05-23 18:10:45 UTC
Ready for QA.
Comment 23 frank.meies 2008-05-23 18:12:55 UTC
.
Comment 24 joerg.skottke 2008-06-03 15:05:49 UTC
Works ok, verified.
Comment 25 joerg.skottke 2008-10-22 10:38:08 UTC
Fixed, closed.