Issue 59205 - Formulas inserted programmatically don't auto-size
Summary: Formulas inserted programmatically don't auto-size
Status: CLOSED FIXED
Alias: None
Product: Writer
Classification: Application
Component: programming (show other issues)
Version: OOo 2.0
Hardware: PC Linux, all
: P3 Trivial with 4 votes (vote)
Target Milestone: ---
Assignee: michael.ruess
QA Contact: issues@sw
URL:
Keywords:
: 62089 (view as issue list)
Depends on:
Blocks:
 
Reported: 2005-12-11 17:05 UTC by remyblank
Modified: 2013-08-07 14:43 UTC (History)
3 users (show)

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


Attachments
Document showing wrongly-sized formulas (24.62 KB, application/vnd.oasis.opendocument.text)
2005-12-11 17:06 UTC, remyblank
no flags Details
Pseudo-code that inserts a formula into a Writer document (1.14 KB, text/plain)
2005-12-11 17:14 UTC, remyblank
no flags Details
Sample with OO Basic Macro (8.15 KB, application/vnd.oasis.opendocument.text)
2006-02-16 09:58 UTC, michael.ruess
no flags Details
Sample document with macro calling lock-/unlockControllers to solve the problem (8.19 KB, application/octet-stream)
2006-03-06 13:46 UTC, thomas.lange
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description remyblank 2005-12-11 17:05:35 UTC
I use a Java UNO application to insert formulas into a Writer document. Up to
OOo 1.1.5, this worked very well, formulas were all inserted and automatically
got the correct size.

Trying the same code on OOo 2.0, the formulas now always get a size of
0.20x0.47. If I double-click on one a formula, it expands and auto-resizes to
the correct size.

I can set the Width and Height properties through UNO and resize the formulas,
but I wasn't able to have them take the correct size by themselves.

I will attach a sample document, as well as the code I use to generate it.
Comment 1 remyblank 2005-12-11 17:06:23 UTC
Created attachment 32280 [details]
Document showing wrongly-sized formulas
Comment 2 remyblank 2005-12-11 17:07:24 UTC
In the attached document, all formulas were inserted through UNO. The second
formula was edited and therefore reverted to the correct size.
Comment 3 remyblank 2005-12-11 17:14:19 UTC
Created attachment 32281 [details]
Pseudo-code that inserts a formula into a Writer document
Comment 4 remyblank 2005-12-11 17:19:23 UTC
The pseudo-code above isn't a complete test case, but shows how I insert
formulas into a Writer document. It is derived from the developer's guide,
section 7.3.10 "Embedded objects".

Up to OOo 1.1.5, formulas were first inserted with the wrong size (probably also
something like 0.20x0.47cm), but when the insertion process was finished, they
popped to the right size one after the other.
Comment 5 michael.ruess 2006-02-16 09:58:57 UTC
Created attachment 34213 [details]
Sample with OO Basic Macro
Comment 6 michael.ruess 2006-02-16 10:00:29 UTC
MRU->TL: when working with Math Formulas via API, the formula objects won't get
updated anymore in OO 2. See attached documents.
Comment 7 michael.ruess 2006-02-16 10:03:34 UTC
*** Issue 62089 has been marked as a duplicate of this issue. ***
Comment 8 cdeval 2006-02-16 10:28:52 UTC
I had the same problem (see issue 62089)
I hope it will be resolved quickly.
My program CmathOOo waits about it (see cdeval.free.fr).
Thank's to developper.
Comment 9 thomas.lange 2006-02-27 09:56:12 UTC
.
Comment 10 thomas.lange 2006-03-02 10:30:27 UTC
Basic macro illustrating the issue:

============================
Sub Main

	oDoc = ThisComponent
	
	TEObj = oDoc.createInstance("com.sun.star.text.TextEmbeddedObject")
	TEObj.setPropertyValue("CLSID", "078B7ABA-54FC-457F-8551-6147e776a997")
	TEObj.setPropertyValue("AnchorType",
com.sun.star.text.TextContentAnchorType.AS_CHARACTER)
	
	xText = oDoc.getText()
	xRange = xText.getEnd()
	xText.insertTextContent(xRange, TEObj, false)
	
	math = TEObj.getEmbeddedObject()
	math.setPropertyValue("Formula", "{x+y} over z")

End Sub
============================
Comment 11 thomas.lange 2006-03-06 13:44:05 UTC
Files changed:
- sfx2/inc/sfxbasemodel.hxx    (gain acces to postEvent_Impl in derived classes)

- starmath/inc/unomodel.hxx    (overload lock-/unlockControllers to send
notification for SFX_EVENT_VISAREACHANGED)
- starmath/source/unomodel.cxx


TL->MAV:
The above code changes will work if a client is available.
For example in Writers unoframe.cxx we modified
SwXTextEmbeddedObject::getEmbeddedObject to have the following lines

: if ( svt::EmbeddedObjectRef::TryRunningState( xIP ) )
:         {
:     SwWrtShell *pSh = pDoc->GetDocShell()->GetWrtShell();
:     SfxInPlaceClient* pClient = pSh->GetView().FindIPClient( xIP, (Window *)
&pSh->GetView().GetEditWin() );
:     if ( !pClient )
:         pClient = new SwOleClient( &pSh->GetView(),
&pSh->GetView().GetEditWin(), pOleNode->GetOLEObj().GetObject() );

But since that location isn't the best of choices please have the client be
created elsewhere.
Also check if it is Ok to have the change visible even if unlockControllers was
not yet called.

Comment 12 thomas.lange 2006-03-06 13:46:24 UTC
Created attachment 34610 [details]
Sample document with macro calling lock-/unlockControllers to solve the problem
Comment 13 mikhail.voytenko 2006-03-06 17:02:18 UTC
It looks like I was wrong when I thought that the call
"SwXTextEmbeddedObject::getEmbeddedObject()" might be used during document
loading. So it should be safe enough to solve the problem in this method.
But instead of direct usage of view shell MBA has reccomended to use synchron
notification to trigger client creation.
Comment 14 mikhail.voytenko 2006-03-08 14:03:05 UTC
The problem is fixed now for all the container document types. If an embedded
object model is retrieved using UNO API the related client is created, so the
object resizing in handled correctly.
Comment 15 mikhail.voytenko 2006-03-08 14:12:25 UTC
Please use following macro to test insertion to Impress, Draw, Calc:

=======================================================
Sub Main

	oDoc = ThisComponent
	oPage = oDoc.getDrawPages().getByIndex( 0 )
	
	oShape = oDoc.createInstance( "com.sun.star.drawing.OLE2Shape" )
	oPage.add( oShape )
	oShape.setPropertyValue("CLSID", "078B7ABA-54FC-457F-8551-6147e776a997")
		
	math = oShape.getPropertyValue( "Model" )
	math.setPropertyValue("Formula", "{x+y} over z")

End Sub
=======================================================
Comment 16 cdeval 2006-03-26 13:21:09 UTC
Hi,
I'm happy to see the "status:resolved"
I downloaded the lat developper snapshot version and the problem is still here.
I'm probably too much impatient and the problem will be really solved in 2.0.3
version... won't it ? 
But it would be a pity to waste time.
Currently the following macro still not work properly :

Sub Main
    oViewCursor = ThisComponent.getCurrentController().getViewCursor()
    oViewCursor.Charheight=12
    oViewCursor.Text.insertString(oViewCursor, "toto", FALSE)
	oViewCursor.goLeft(4,True)
    oDesktop = createUnoService("com.sun.star.frame.Desktop")
    document   = ThisComponent.CurrentController.Frame
    dim Array(0) as new com.sun.star.beans.PropertyValue
    dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
    dispatcher.executeDispatch(document, ".uno:InsertObjectStarMath", "", 0,Array())
    obj=ThisComponent.getCurrentSelection()
    'changement du texte de la formule
    obj.EmbeddedObject.formula="{1}over{3}"
    'changement de la taille
    obj.EmbeddedObject.BaseFontHeight=25
    'rafraichissement
    obj.EmbeddedObject.setmodified(TRUE)
    dispatcher.executeDispatch(document, ".uno:Escape", "", 0, Array())
    dispatcher.executeDispatch(document, ".uno:ResetAttributes", "", 0, Array())
End Sub 
Comment 17 thomas.lange 2006-04-26 11:21:54 UTC
TL->Cdeval : Of course the problem is not fixed in the developer builds. The CWS
is not even ready for QA yet. You have to wait until the CWS is integrated.
Comment 18 thomas.lange 2006-04-26 11:31:57 UTC
TL->QA: Works fine with the macro attached by me. 
However as I understood MAV once lock-/unlockControllers should better not be
used since it is not yet guaranteed to work. Even though to me everything looks
find independent of if those functions get used or not.


re-open issue and reassign to cn@openoffice.org
Comment 19 thomas.lange 2006-04-26 11:32:01 UTC
reassign to cn@openoffice.org
Comment 20 thomas.lange 2006-04-26 11:32:05 UTC
reset resolution to FIXED
Comment 21 chne 2006-04-27 09:25:25 UTC
ok in tl18
Comment 22 chne 2006-06-26 20:30:27 UTC
ok in src680_m173 -> close
Comment 23 cdeval 2006-07-07 11:14:27 UTC
Hello,
Thank's for the issue. But the problem is half-resolved.
When the text of formula changes, the box auto-size -> success !
When the size of formula changes, the box doesn't auto-size. And it was with
OOo1.1.5 !

type following macro to see the problem :

Sub Main

	oDoc = ThisComponent
	TEObj = oDoc.createInstance("com.sun.star.text.TextEmbeddedObject")
	TEObj.setPropertyValue("CLSID", "078B7ABA-54FC-457F-8551-6147e776a997")
	TEObj.setPropertyValue("AnchorType",
com.sun.star.text.TextContentAnchorType.AS_CHARACTER)
	xText = oDoc.getText()
	xRange = xText.getEnd()
	xText.insertTextContent(xRange, TEObj, false)
	
	math = TEObj.getEmbeddedObject()
	' Youpi : now the following line resizes box
	math.setPropertyValue("Formula", "{x+y} over z")
	' but not with this line :
	math.BaseFontHeight=25
	' and not with this line too :
	math.setmodified(TRUE)

End Sub

Thank's for your help.
Comment 24 michael.ruess 2006-07-12 18:05:56 UTC
*** Issue 67283 has been marked as a duplicate of this issue. ***
Comment 25 cdeval 2006-10-13 20:45:26 UTC
Hello,

I tried my macro with version 2.0.4 and the bug is still here.
The problem is half-resolved, when I change the text of formula, it autosizes,
when I change the size of character, it doesn't.

Many users are affected by this bug (using Dmaths or CmathOOo).
Please, please, help....
It was fine in 1.1.5 !!!!!
Comment 26 chne 2006-12-04 09:02:26 UTC
cn->cdeval: please submitt another issue for you problem
Comment 27 cdeval 2007-12-07 22:15:51 UTC
Hi,

In OOo version 2.3.1, bug 59205 has returned. Try my macro above to see the problem.
Many teachers and students use addons such as Dmaths or CmathOOo wich no longer
work.
Thank's for your help.
Comment 28 charlysalmon 2007-12-08 11:41:38 UTC
http://qa.openoffice.org/issues/showvotes.cgi?voteon=59205
Vote for this issue

This issue should be re-open the bug is stil there (version 2.3.1)
Comment 29 cdeval 2007-12-08 13:26:01 UTC
> This issue should be re-open the bug is stil there (version 2.3.1)

I would say : the bug was fixed until version 2.3.0 and came back in 2.3.1 !
Comment 30 brunohenry 2007-12-19 20:47:56 UTC
This bug is still alive in 2.3.1
Comment 31 chne 2008-03-13 19:58:09 UTC
reopen
Comment 32 chne 2008-03-13 19:59:38 UTC
cn->tl: it seems that the issue is not fixed at all. Please run the macro from
cdeval, posted on Fri Jul 7 10:14:27 2006 
Comment 33 thomas.lange 2008-03-14 11:06:34 UTC
TL: Please see issue i67283 and the comments about issue i85282 in it.
The first one is already fixed. And when the later one is as well and both fixes
are integrated in the master then this problem should vanish again. 
(It already was, but somehow came up again.)

TL->MAV: Please keep this issue and check it again when you have fixed i85282.
If unexpectedly there will be still some problem please hand it back to me.
Otherwise it will be a duplicate.
Comment 34 mikhail.voytenko 2008-06-03 15:04:32 UTC
.
Comment 35 mikhail.voytenko 2008-06-17 11:16:30 UTC
The fix seems to be removed by chart2mst3 cws integration. Should be back now.
MAV->MRU: Could you please verify the issue in fwk90.
Comment 36 thorsten.martens 2008-06-25 13:30:27 UTC
TM->SBA: MRU is on vacation, so please take over and verify this issue, thanks
in advance.
Comment 37 cdeval 2008-07-01 08:21:41 UTC
Hi,
Currently this issue is not fixed in dev300_m21.
Please help ! Many teachers await this fix to use Dmaths and CmathOOo extensions
again for scientific texts. In France, M$ gives Office 2007 to all teachers for
free (with a new scientific editor). With this bug, we are disarmed.
It is very disappointing because it worked fine with OOo 2.2.1
Thank's a lot.
Comment 38 stefan.baltzer 2008-07-01 15:30:07 UTC
Reassigned to MRU.
Comment 39 stefan.baltzer 2008-07-01 15:31:39 UTC
Reassigned to MRU.
Comment 40 stefan.baltzer 2008-07-01 15:37:20 UTC
SBA: Verified in CWS fwk90.
Comment 41 michael.ruess 2008-08-05 11:47:20 UTC
Checked the fix in DEV300m29.