Apache OpenOffice (AOO) Bugzilla – Full Text Issue Listing |
Summary: | ActualSize of com.sun.star.text.TextGraphicObject is not initialized if pic inserted programmatically. | ||
---|---|---|---|
Product: | Writer | Reporter: | villeroy <villeroy> |
Component: | code | Assignee: | michael.ruess |
Status: | CLOSED FIXED | QA Contact: | issues@sw <issues> |
Severity: | Trivial | ||
Priority: | P3 | CC: | issues, kpalagin, Mathias_Bauer, os_ooo, samuel.hartmann.ch |
Version: | OOo 2.3.1 | Keywords: | regression |
Target Milestone: | 3.4.0 | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | DEFECT | Latest Confirmation in: | --- |
Developer Difficulty: | --- |
Description
villeroy
2008-01-09 12:52:48 UTC
jsc -> tl:seems to be one for you . Although issue 97291 is different, they may have related solutions: http://www.openoffice.org/issues/show_bug.cgi?id=97291 *** Issue 95730 has been marked as a duplicate of this issue. *** added assignee from 95730 to CC Reassigned to od ->od: The property is queried from SwGrfNode::GetTwipSize(). Oliver, thanks a lot! As 2.1 does not have this bug I set keyword regression. Oliver, any chance to fix this issue for 3.2? Thanks a lot for your attention. WBR, KP. Investigation reveals the following: The graphic is inserted as a link. Thus, the intrinsic graphic is loaded asynchronous in a background thread - issue 73788. Until the graphic is completely loaded its "ActualSize" attribute is not initialized. Unfortunately, the "ActualSize" attribute is requested before the graphic is completely loaded. Possible solutions: A: Perform something like "busy-waiting" on accessing the "ActualSize" attribute - loop of access; check, if set; if set then go on else wait a moment and perform loop-body again. B: Trigger a synchronous load of a linked graphic on request its "ActualSize" attribute. I vote for solution A. Otherwise the advantages of the asynchronous load of linked graphics are partly lost - see issue 73788 OD->villeroy, kpalagin: What is your opinion? Option C could be a remark in the documentation that certain properties, such as ActualSize, are availlable after the picture has been loaded completely. I vote for option A. *** Issue 100157 has been marked as a duplicate of this issue. *** I also experienced problems with the property "ActualSize" of a TextGraphicObject. And I am sure that the bug it is not just due to the asynchronous loading of the image in the background. The proposed solution A does not work for me. My basic macro looped forever if I did not trigger by some other means the update of the ActualSize property. I have found that watching the contents of the TextGraphic object in the OOo Basic IDE updates the field ActualSize. Also using XRay (http://ooomacros.org/dev.php#101416) to inspect the object updates the ActualSize field. I then identified the line in the XRay macro which triggers the update. The field is updated when the property "IsPixelContour" is read: oTextGraphic.getPropertyValue("IsPixelContour") I am now using this in my routine to update an existing graphic or create a new graphic. The code is the following: Function ImportBitmapIntoWriter(sFile As String, Optional oTextGraphic) As Object ' Imports a bitmap into Writer Dim oDoc As Object Dim oBitmaps As Object Dim sNewUrl As String Dim oCursor As Object Dim oText As Object Const INCH = 2540 oDoc = ThisComponent ' Load the image into the internal bitmap table oBitmaps = oDoc.createInstance("com.sun.star.drawing.BitmapTable") oBitmaps.insertByName( "OOoLilyPond", ConvertToURL(sFile) ) sNewURL = oBitmaps.getByName( "OOoLilyPond" ) ' Create a new TextGraphic Object, if needed If IsMissing(oTextGraphic) Then oCursor=oDoc.getCurrentController().getViewCursor() oText = oCursor.getText() oTextGraphic = oDoc.createInstance("com.sun.star.text.GraphicObject") oTextGraphic.GraphicURL = sNewURL oTextGraphic.AnchorType = com.sun.star.text.TextContentAnchorType.AS_CHARACTER oText.insertTextContent( oCursor, oTextGraphic, False ) End If ' remove the Bitmap from the table ' (otherwise the Bitmaps of deleted Objects will still be referenced and saved) oBitmaps.removeByName( "OOoLilyPond" ) ' this triggers the updating of the property "ActualSize" ' see http://www.openoffice.org/issues/show_bug.cgi?id=85105 oTextGraphic.getPropertyValue("IsPixelContour") ' set the original graphic size oTextGraphic.setSize(oTextGraphic.ActualSize) ' oTextGraphic ' select the object oDoc.getCurrentController().select(oTextGraphic) 'return the TextGraphic object ImportBitmapIntoWriter = oTextGraphic End Function If reading "IsPixelContour" triggers the update of "ActualSize". It should be implemented that reading "ActualSize" also triggers the same action. Or alternatively if there is really a time delay due to the asynchronous loading of the image there should be a property "GraphicIsLoaded" and a method "WaitForGraphicLoaded". Samuel Please don't implement option "A" - this is a can of worms. Switching to synchronous loading is better. I revoke my vote for option A and vote for B now. I believe that mba is more knowledgeable than me. fixed in cws sw34bf05 - changed files: /sw/source/core/unocore/unoframe.cxx, /sw/source/core/graphic/ndgrf.cxx, change set http://hg.services.openoffice.org/cws/sw34bf05/rev/e051950c25cd forgot to adjust status reviewed code to fix this issue with OS od->mru: Checked in internal installation set of cws sw34bf05 - please verify. Verified fix in CWS sw34bf05. |