Page 1 of 1

[Solved] Inserting OLE Objects (Charts/Formulae/etc)

Posted: Fri May 10, 2013 9:59 am
by SNM90
Hello,

I was trying to figure out how to insert Charts/Formulae/Other OLE Objects into Writer programmatically, and I've figured out till now the service to use is css::text::TextEmbeddedObject. Now here I see that a certain property namely 'string CLSID' determines exactly what gets inserted into it's base frame at the cursor. Now my question is how exactly is this CLSID of different objects determined? I couldn't find any documentation listing these separately for each type. Also, am I on the right track? How to go about this type of insertion? Preferably in C++/Java.

Thanks in advance.

Re: Inserting OLE Objects (Charts/Formulae/etc)

Posted: Sat May 11, 2013 9:25 am
by SNM90
*Bump*

Re: Inserting OLE Objects (Charts/Formulae/etc)

Posted: Sat May 11, 2013 10:55 am
by RoryOF

Re: Inserting OLE Objects (Charts/Formulae/etc)

Posted: Sat May 11, 2013 11:46 am
by SNM90
Hmm... in any case, I guess it's a standard. So for Charts/Formula, I'm now using the same one as mentioned in other codes I see on the forums.

Now I face another problem, I'm able to see charts and formulas as OLE objects after my program gets executed, but for formulas particularly, I'm not able to get how to insert the formula inside that formula box programmatically (Java/C++). OOBasic codes have not helped me at all, and I can't find anything on this in Java or C++. A little help on this?

To compress my problem: Need help in inserting formulas inside the formula box I got through a program. My current program to display it is like:

Code: Select all

Any clsid;
clsid <<= OUString::createFromAscii("078b7aba-54fc-457f-8551-6147e776a997");
xPropSet->setPropertyValue("CLSID", clsid);
xText->insertTextContent(xTextRange, xTextContent, false);
Also, how to I get to open the Formula element window automatically on running?

Re: Inserting OLE Objects (Charts/Formulae/etc)

Posted: Sat May 11, 2013 6:33 pm
by hanya
Somthing like this in C++:

Code: Select all

        // insert Formula
        Reference< XInterface > xTextEmbedded(
                xMsf->createInstance( A2S( "com.sun.star.text.TextEmbeddedObject" ) ), UNO_SET_THROW );
        Reference< XPropertySet > xPropSet( xTextEmbedded, UNO_QUERY_THROW );
        xPropSet->setPropertyValue( A2S( "CLSID" ), makeAny( A2S( "078B7ABA-54FC-457F-8551-6147e776a997" ) ) );
        
        Reference< XTextContent > xTextContent( xTextEmbedded, UNO_QUERY_THROW );
        xText->insertTextContent( xTextRange, xTextContent, sal_False );
        
        Reference< XEmbeddedObjectSupplier2 > xEmbeddedSupp( xTextEmbedded, UNO_QUERY_THROW );
        Reference< XComponent > xEmbeddedComp( xEmbeddedSupp->getEmbeddedObject(), UNO_SET_THROW );
        
        Reference< XPropertySet > xFormulaPropSet( xEmbeddedComp, UNO_QUERY_THROW );
        xFormulaPropSet->setPropertyValue( A2S( "Formula" ), makeAny( A2S( "x + y" ) ) );
        
        // edit Formula inserted
        Reference< XEmbeddedObject > xEmbeddedObject( 
                xEmbeddedSupp->getExtendedControlOverEmbeddedObject(), UNO_QUERY_THROW );
        xEmbeddedObject->doVerb( -1 ); // hard to know without looking on its menu label?
OOBasic codes have not helped me at all
What's wrong with it from converting Basic code to C++ or Java?

Re: Inserting OLE Objects (Charts/Formulae/etc)

Posted: Sun May 12, 2013 5:59 am
by SNM90
Oh damn! I wasn't using Embedded Object Supplier interface! :O Just totally missed it. Was trying to directly access the formula properties. From BASIC, it isn't clear as they directly write obj.CLSID = something and then obj.EmbeddedObject.Formula = something. The latter confused me. Sorry if this question was dumb! :(