Bug 67421 - API: some of embedded objects' models in a document are not accessible
Summary: API: some of embedded objects' models in a document are not accessible
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: Other All
: medium normal
Assignee: Mike Kaganski
URL:
Whiteboard: target:5.0.0
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-28 00:50 UTC by Mike Kaganski
Modified: 2023-06-02 09:33 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
Testcase (502.97 KB, application/vnd.oasis.opendocument.text)
2013-07-28 00:50 UTC, Mike Kaganski
Details
ODT with 100 formulas and provided macro. (231.59 KB, application/vnd.oasis.opendocument.text)
2013-12-21 11:38 UTC, Owen Genat (retired)
Details
Screencasts (2.33 MB, application/x-zip-compressed)
2013-12-22 07:51 UTC, Mike Kaganski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Kaganski 2013-07-28 00:50:55 UTC
Created attachment 83109 [details]
Testcase

In the attached document, there are a lot of formula objects embedded (all have a stub formula text: "A Formula"). When trying to manipulate them using Basic, some of their models return empty or null.

To reproduce, execute the following macro on the document:

sub tst()
  embeddedObjects = ThisComponent.getEmbeddedObjects()
  k = 0
  for each oMathObject in embeddedObjects
    oModel = oMathObject.Model
    if ((not isNull(oModel)) and (not isEmpty(oModel))) then
      oModel.Formula=Format(k)
      oMathObject.ExtendedControlOverEmbeddedObject.Update()
    end if
    k=k+1
  next
end sub

This macro should simply replace the formulas in the objects with a number. However, some objects still contain text "A Formula" after the operation. They seem to be at specific positions (in this case, they are objects in lines 21, 42, 63, ...)

Tested with 3.3.0.4, 4.1.0.4, AOO 4.0 under Win7x64. Seems like an inherited bug.
Comment 1 Mike Kaganski 2013-08-10 06:18:51 UTC
As a workaround, the following code may be used:

...
      oModel = oMathObject.Model
      if (isNull(oModel) or isEmpty(oModel)) then ' Workaround Bug 67421
        oModel = oMathObject.Model
      end if
      if ((not isNull(oModel)) and (not isEmpty(oModel))) then
...

i.e. the second time the same function on the same object returns the requested model just fine!
Comment 2 Owen Genat (retired) 2013-12-21 11:38:24 UTC
Created attachment 91078 [details]
ODT with 100 formulas and provided macro.

I can't confirm this bug. If I download the provided example and add the provided macro code then it works as indicated. The attached example however that I created from scratch under Ubuntu 10.04 x86_64 using v4.1.3.2 does not appear to work. No formulas are changed from running the macro.
Comment 3 Mike Kaganski 2013-12-22 07:51:47 UTC
Created attachment 91115 [details]
Screencasts

(In reply to comment #2)
Hi Owen Genat,
thank you for looking into this!

> I can't confirm this bug. If I download the provided example and add the
> provided macro code then it works as indicated.
Do you mean that you do reproduce the problem with my file?

> The attached example however
> that I created from scratch under Ubuntu 10.04 x86_64 using v4.1.3.2 does
> not appear to work. No formulas are changed from running the macro.
Do you mean that in your file, all formulas keep the text “AFormula” after executing the macro?

Here are the screencasts where I try your file with 4.1.3.2 under Win7x64 and Ubuntu 13.10 x64. Both show the same: the problem is 100% reproducible.
Comment 4 pierre-yves samyn 2014-01-18 10:20:32 UTC
Hello

I reproduce on windows 7/64 with Version: 4.2.0.2
Build ID: cd65d6220c5694ee7012d7863bcde3455c9e3c30

The problem is not caused by the formula. This can be checked by moving the paragraph up (Ctrl + Alt + Up).

The problem seems related to the number of update: it always occurs after 21 occurrences of:

oMathObject.ExtendedControlOverEmbeddedObject.Update()

Another workaround:

sub tst()

  embeddedObjects = ThisComponent.getEmbeddedObjects()
  k = 0
  for each oMathObject in embeddedObjects
    oModel = oMathObject.Model
    if ((not isNull(oModel)) and (not isEmpty(oModel))) then
      oModel.Formula=Format(k)
'      oMathObject.ExtendedControlOverEmbeddedObject.Update()
    end if
    k=k+1
  next

document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dispatcher.executeDispatch(document, ".uno:UpdateAll", "", 0, Array())

end sub


Regards
Pierre-Yves
Comment 5 Owen Genat (retired) 2014-01-18 11:30:16 UTC
(In reply to comment #3)
> (In reply to comment #2)
> > I can't confirm this bug. If I download the provided example and add the
> > provided macro code then it works as indicated.
> Do you mean that you do reproduce the problem with my file?

Yes. Sorry Mike, I should have been clearer in stating that I could reproduce the problem using your file, but could not create a file from scratch to re-produce the problem. In this sense (your file) I can confirm the issue. Thanks for producing the screencast that clearly indicates the same problem with my file. I have no idea why my file does not work here. I am a little bit disturbed that it doesn't.
Comment 6 Joel Madero 2015-05-02 15:42:31 UTC
** Please read this message in its entirety before responding **

To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year.

There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present.

If you have time, please do the following:

   Test to see if the bug is still present on a currently supported version of LibreOffice (4.4.2 or later)
   https://www.libreoffice.org/download/

   If the bug is present, please leave a comment that includes the version of LibreOffice and your operating system, and any changes you see in the bug behavior
 
 If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a short comment that includes your version of LibreOffice and Operating System

Please DO NOT

   Update the version field
   Reply via email (please reply directly on the bug tracker)
   Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not appropriate in this case)


If you want to do more to help you can test to see if your issue is a REGRESSION. To do so: 1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3)

http://downloadarchive.documentfoundation.org/libreoffice/old/

2. Test your bug 3. Leave a comment with your results. 4a. If the bug was present with 3.3 - set version to "inherited from OOo"; 4b. If the bug was not present in 3.3 - add "regression" to keyword


Feel free to come ask questions or to say hello in our QA chat: http://webchat.freenode.net/?channels=libreoffice-qa

Thank you for your help!

-- The LibreOffice QA Team This NEW Message was generated on: 2015-05-02
Comment 7 Mike Kaganski 2015-05-02 17:36:26 UTC
Still reproducible with Version: 4.4.3.2
Build ID: 88805f81e9fe61362df02b9941de8e38a9b5fd16
Locale: ru_RU
under Win7x64
Comment 8 Mike Kaganski 2015-05-17 14:19:20 UTC
Submitted patch to gerrit: https://gerrit.libreoffice.org/15772
Comment 9 Commit Notification 2015-05-19 14:44:48 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=b717bda1f6484905aebc571c4538165a1fbfd2bb

tdf#67421: Prevent unloading objects due to cache full

It will be available in 5.0.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.