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

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
SNM90
Posts: 21
Joined: Fri Mar 01, 2013 6:56 am

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

Post 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.
Last edited by SNM90 on Sun May 12, 2013 6:00 am, edited 2 times in total.
OpenOffice 3.1 on Windows Vista
(Libreoffice 4.0.0 on Windows 7)
SNM90
Posts: 21
Joined: Fri Mar 01, 2013 6:56 am

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

Post by SNM90 »

*Bump*
OpenOffice 3.1 on Windows Vista
(Libreoffice 4.0.0 on Windows 7)
User avatar
RoryOF
Moderator
Posts: 34612
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

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

Post by RoryOF »

Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
SNM90
Posts: 21
Joined: Fri Mar 01, 2013 6:56 am

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

Post 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?
OpenOffice 3.1 on Windows Vista
(Libreoffice 4.0.0 on Windows 7)
hanya
Volunteer
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

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

Post 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?
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
SNM90
Posts: 21
Joined: Fri Mar 01, 2013 6:56 am

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

Post 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! :(
OpenOffice 3.1 on Windows Vista
(Libreoffice 4.0.0 on Windows 7)
Post Reply