ImproveMathEquationEditor/Baseline AlignmentEquations/E mails

From Wiki.ooo4kids.org

Jump to: navigation, search

mba->Spiso->mba->Spiso mail in one to make it shorter

Michal Spisiak
 to Mathias, ericb, Thomas
	
show details Jun 14
	
Hi Mathias,

On Sat, Jun 12, 2010 at 7:09 PM, Mathias Bauer <Mathias.Bauer@sun.com> wrote:

    Hi Michal,


    On 12.06.2010 04:33, Michal Spisiak wrote:


        On Fri, Jun 11, 2010 at 11:38 AM, Mathias Bauer <Mathias.Bauer@sun.com
        <mailto:Mathias.Bauer@sun.com>> wrote:

           Hi,

           after discussing that with Thomas, here's my recommendation:

           We could add a "BaseLine" property to the property set of the
           SmModel. So in Writer you would put the formula object into
           "running" state, access its model, query for the
           com::sun::star::beans::XPropertySet interface and ask for the
           property "BaseLine".

        Yeah, that would be great, I just have to learn how to use it. :) By
        "running" state you mean that the StarMath has to be activated (in
        progress)?


    Correct. You can find code that activates the object everywhere in Writer. You can find an example (that also works with the propertyset API of a Math document) in sw/source/ui/wrtshell/wrtsh1.cxx.


Thanks for the example.
If I understood correctly, it should look like this:

   564 	SvGlobalName aCLSID( xRef->getClassID() );
   565 	bStarMath = ( SotExchange::IsMath( aCLSID ) != 0 );


   572  if bStarMath 
   573 	if( svt::EmbeddedObjectRef::TryRunningState( xRef.GetObject() ) )
   574 	{
   575 		uno::Reference < beans::XPropertySet > xSet( xRef->getComponent(), uno::UNO_QUERY );

   576 		if ( xSet.is() )
   577 		{
   578 			try
   579 			{
   580 				nBaseline = xSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BaseLine") ) );
   582 			}
   583 			catch ( uno::Exception& )

   584 			{
   585 			}
   586 		}
   587 	}

From the other end - starmath, the value has to be set. I found that there are some things assigned to the property set in

starmath/source/mathmlexport.cxx
line 102
method SmXMLExportWrapper::Export

If I just put it there as all the others with property name "BaseLine" will the transfer work? or does it need some other defining somewhere else?

 



           This property may be identical with an nBaseline from an SmNode, but
           in most cases it needs to be calculated in a way that - AFAIK -
           still needs to be defined.

        Might be true, but my impression is that there is no additional
        calculation needed. If interested can read about it here

        http://wiki.ooo4kids.org/index.php/ImproveMathEquationEditor/Baseline_AlignmentEquations#Baseline_of_Sm_object


    That was quite some time ago, I need to make me familiar with that discussion again.




           Your implementation should make sure that the property is queried
           only if really necessary, that means if the formula was changed
           (then the model of the formula is loaded anyway) or if the formula
           needs to be repositioned. IIRC I have written about that in the
           issue comments.


        I read that, but in my opinion cdeval was in that discussion right. Also
        explained here

        http://wiki.ooo4kids.org/index.php/ImproveMathEquationEditor/Baseline_AlignmentEquations#Introduction


    I have to read that also. Anyway, however we implement it, IMHO it is not acceptable that formula objects will be loaded always just for positioning in the layout if they are baseline aligned.

Yes, my solution doesn't require loading it every time. Just when the formula is changed, there is slight problem with putting border on the formula object I'll think of it also.
BTW I update the site every day so there are some screenshots now, that might help to explain
 

    Regards,
    Mathias


cheers

Michal

response by tl

Thomas Lange - Sun Microsystems
 to me, Mathias, ericb
	
show details Jun 14
	

Hi Michael,


> From the other end - starmath, the value has to be set. I found that there are some things assigned to the property set in
>
> starmath/source/mathmlexport.cxx
> line 102
> method SmXMLExportWrapper::Export
>
> If I just put it there as all the others with property name "BaseLine" will the transfer work? or does it need some other defining somewhere else?

Nope that is wrong. As the file name indicates that one has only to do with MathML.
What you need is the code implementing the getPropertyValue at the UNO model. That is where the service named 'FormulaProperties' is implemenmted. And that is 'SmModel::_getPropertyValues', this is where you need to implement that property (or better said: provide it to the public via UNO).



>         Might be true, but my impression is that there is no additional
>         calculation needed. If interested can read about it here
>
>         http://wiki.ooo4kids.org/index.php/ImproveMathEquationEditor/Baseline_AlignmentEquations#Baseline_of_Sm_object
>
>
>     That was quite some time ago, I need to make me familiar with that discussion again.
>

Calculation should still be needed for at least
- A over B (SmBinVerNode)
- stack + binom (SmTableNode)
- and matrices (SmMatrixNode)
In those cases the call to HasBaseline should be false right now.
I may be missing one or two though.


Thomas

my response to Thomas (tl), which was basically correct, later implemented in

Michal Spisiak
 to Thomas.Lange, Mathias, ericb
	
show details Jun 15
	
Hi Thomas,

On Mon, Jun 14, 2010 at 7:20 AM, Thomas Lange - Sun Microsystems <Thomas.Lange@sun.com> wrote:


    Hi Michael,


>     From the other end - starmath, the value has to be set. I found that there are some things assigned to the property set in
>
>     starmath/source/mathmlexport.cxx
>     line 102
>     method SmXMLExportWrapper::Export
>
>     If I just put it there as all the others with property name "BaseLine" will the transfer work? or does it need some other defining somewhere else?

    Nope that is wrong. As the file name indicates that one has only to do with MathML.
    What you need is the code implementing the getPropertyValue at the UNO model. That is where the service named 'FormulaProperties' is implemenmted. And that is 'SmModel::_getPropertyValues', this is where you need to implement that property (or better said: provide it to the public via UNO).

Sorry to bother you with all of these. I had a look at the SmModel::_getPropertyValues and to be sure hopefully last question:
What I would do is to add there case

case HANDLE_BASELINE:
{
  *pValue <<= (sal_Int16) pDocSh->pTree->GetBaseline();
}

and add HANDLE_BASELINE to

enum SmModelPropertyHandles
(defined in the same file unomodel.cxx)

and to
static PropertyMapEntry aModelPropertyInfoMap[ ]
as
{ RTL_CONSTASCII_STRINGPARAM( "BaseLine"), HANDLE_BASELINE, &::getCppuType((const sal_Int16*)0), PROPERTY_NONE, 0}

then in Sw just asked through getPropertyValue for "Baseline"



>             Might be true, but my impression is that there is no additional
>             calculation needed. If interested can read about it here
>
>             http://wiki.ooo4kids.org/index.php/ImproveMathEquationEditor/Baseline_AlignmentEquations#Baseline_of_Sm_object
>
>
>         That was quite some time ago, I need to make me familiar with that discussion again.
>

    Calculation should still be needed for at least
    - A over B (SmBinVerNode)
    - stack + binom (SmTableNode)
    - and matrices (SmMatrixNode)
    In those cases the call to HasBaseline should be false right now.
    I may be missing one or two though.

There is something strange about these, I let Sm to draw baseline for SmTableNode (with condition on HasBaseline) and it does draw it for all of those that you listed. Even it looks as a sensible value, might be just by chance but I tried some crazy equations and it worked well. The real problem with these I would say is to define what we consider as "well", I doubt there exist some rule for where the baseline should be for such formulas.
 
 many thanks

Michal
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox