Issue 100374 - Changes to Notes via UNO API are not persistent anymore
Summary: Changes to Notes via UNO API are not persistent anymore
Status: CLOSED FIXED
Alias: None
Product: Writer
Classification: Application
Component: programming (show other issues)
Version: OOo 3.0.1
Hardware: All All
: P2 Trivial (vote)
Target Milestone: ---
Assignee: stefan.baltzer
QA Contact: issues@sw
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2009-03-19 18:30 UTC by mux2005
Modified: 2013-08-07 14:43 UTC (History)
6 users (show)

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


Attachments
File with macro demonstrating the issue (12.12 KB, application/vnd.oasis.opendocument.text)
2009-03-19 18:31 UTC, mux2005
no flags Details
patch (1.37 KB, text/plain)
2009-03-21 12:26 UTC, max.odendahl
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description mux2005 2009-03-19 18:30:19 UTC
Steps to reproduce:

0. Open the attached document (macros must be enabled)

1. Make sure that checkbox Tools/Options.../OpenOffice.org Write/View/Notes is
checked
(Note: The bug is independent of this setting, but the inconsistency between the
new Annotation code and the old API is more apparent this way)

2. You'll see a colored line pointing to a „post-it“ note to the right, reading
„Dies ist eine Notiz“.


3. Open the Navigator (Edit/Navigator or F5) and expand „Notes“. You'll see the
same text „Dies ist eine Notiz“

4. Press the button in the document. A macro will launch that shows 2 message
boxes with the text of the Content property of the annotation textfield, first
before and then after changing said property.


5. Confirm the 2 message boxes

6. Compare the „post-it“ note's text and the Navigator's. The Navigator
correctly reflects the API's POV (which is also what the second message box
prints out). However the post-it note is what is stored when you save the file.

7. Save the file and reopen it. The change to the note has been lost.

This means that any program or extension changing the contents of annotations,
will experience data loss. This is a very serious issue. Our custom form system
depends on annotations. All of the user's entered data is stored in an
annotation and will be lost when the user saves the document.

I can reproduce the issue under Linux and Windows 2000.

Classifying as P2 according to
http://www.openoffice.org/scdocs/ddIssues_EnterModify#priority
because its a regression and causes data loss in an easy-to-encounter way (at
least for the several 1000 users in our organization that use our custom form
system that stores its data in annotations)
Comment 1 mux2005 2009-03-19 18:31:32 UTC
Created attachment 61055 [details]
File with macro demonstrating the issue
Comment 2 mux2005 2009-03-19 18:32:36 UTC
Adding keyword "regression" since this was working in OOo 2.4.x
Comment 3 bmarcelly 2009-03-20 08:54:01 UTC
Confirmed on DEV OOO310m6.
And the document "Save" icon does not activate.

Also modifying the note text by annotation.TextRange does not change the text of 
annotation.Content.
This modified code shows inconsistencies; create a note with text: Hello World

  doc = ThisComponent
  textfields = doc.getTextFields()
  annotation = textfields.createEnumeration().nextElement()

  print 1, annotation.Content           ' --> Hello World
  annotation.Content = "alpha"
  print 2, annotation.Content           ' --> alpha
  annotation.TextRange.String = "delta"
  print 3, annotation.TextRange.String  ' --> Hello
  print 4, annotation.Content           ' --> alpha

IMHO this issue should be a stopper for 3.1.
Comment 4 max.odendahl 2009-03-20 11:10:42 UTC
looking into it....

- did also not work in 3.0
- creating a new note via API works
Comment 5 max.odendahl 2009-03-20 11:16:22 UTC
mod->es: showstopper?
Comment 6 eric.savary 2009-03-20 11:54:34 UTC
@MOD: your "looking into it...." comment...
- so it's not a regression from 3.0 -> 3.0.1?
- only happens when loading doc with "old" (<3.0) notes?
- only happens when modifying them via API.
So, as mux2005 explained, yes, it's a P2 due to the severity.
But because of our schedule and the general use of notes via API I'd still
target 3.2. (no showstopper)

(changed summary for later tracking "Annotations" -> "Notes")
Comment 7 max.odendahl 2009-03-20 12:01:51 UTC
mod->es: 

- no, it is not a regression from 3.0, but from 2.4
- it happens with *all* documents with notes, old ones, new ones, doc, odt 

So I would say this is a showstopper, and I have a save fix, so I can have a cws
and installation sets ready today
Comment 8 eric.savary 2009-03-20 12:22:18 UTC
Ok, go! :)
Please keep in touch via e-mail.
Probably MBA will have to build also internally...
Comment 9 eric.savary 2009-03-20 13:15:24 UTC
STOP!

Sorry for this but thinking about it and after having called about 10 persons:
no we don't take it as showstopper because the regression is not from 3.0 ->
3.1. So no recent regression.
Comment 10 max.odendahl 2009-03-20 13:47:40 UTC
don't really agree, but if everyone else thinks this way, it's fine

will be fixed in cws notes9 for OOo 3.2

mod->mux2005: maybe one workaround for you would be to delete the old note via
API, and insert a new one via API, this should work as well
(of course you could create your own version of released 3.1 including notes9)
Comment 11 mux2005 2009-03-20 15:18:54 UTC
@mod: What do you mean by "new note" ? The note in the example document has been
inserted via GUI "Insert/Note" on OOo 3.0.1. I would assume that's a "new note".
Comment 12 max.odendahl 2009-03-20 15:23:42 UTC
instead of changing the text of an existing one(which does not work as you found
out), you can just delete the old one and create a new one using the API, sth.
like this:

Dim myNote As Object
Dim uneDate As New com.sun.star.util.DateTime
myNote = ThisComponent.createInstance("com.sun.star.text.TextField.Annotation")
myNote.Author = "Somebody" 
myNote.Content = "This is the text of the note"
myText.insertTextContent(myCursor, myNote, False)
Comment 13 mux2005 2009-03-20 15:31:38 UTC
I see. Yes that may be a feasible workaround. We'll have to see if that affects
performance very much.
Comment 14 mux2005 2009-03-20 19:35:22 UTC
@mod: Can you provide a patch that I can backport to 3.0.1?
Comment 15 kpalagin 2009-03-20 20:57:14 UTC
Could this issue be targeted if not for 3.1, then for 3.1.1, if such thing is 
in plans?
Comment 16 max.odendahl 2009-03-21 12:24:46 UTC
fixed in cws notes9
Comment 17 max.odendahl 2009-03-21 12:26:52 UTC
Created attachment 61088 [details]
patch
Comment 18 max.odendahl 2009-04-04 03:23:04 UTC
this should be tested by a unit test, so it does not happen again
Comment 19 max.odendahl 2009-04-06 21:27:42 UTC
seems like someone decided it is 3.1 now, so fixed in fwk111
Comment 20 clutz 2009-04-07 09:05:22 UTC
great information! fwk111 is not included in OOO310_m9 (RC 1). will this be in RC 2?
Comment 21 clutz 2009-04-07 09:19:37 UTC
great information! It seems that fwk111 is not included in OOO310_m9 (RC 1).
will this be in RC 2?
Comment 22 carsten.driesner 2009-04-07 17:23:27 UTC
cd->sba: Please verify.
Comment 23 stefan.baltzer 2009-04-09 09:48:23 UTC
Verified in CWS fwk111.
Comment 24 stefan.baltzer 2009-05-06 12:43:37 UTC
OK in OOO310_m11. Closed.

Note that CWS fwk111 was just cloned by OBO to get these chages into DEV300_m48.