[Solved] [C++] lockControllers() doesn't work on xcalc diagr

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
Gaivota
Posts: 3
Joined: Thu Dec 25, 2014 1:09 pm

[Solved] [C++] lockControllers() doesn't work on xcalc diagr

Post by Gaivota »

Hi,
I've been searching and trying for days without success, so I finally try to ask here.
My problem is the following:
I get data from an arduino over serial port, and automatically feed them into a xcalc spreadsheet.
That works fine, but since the spreadsheet uses a diagram to display the data graphically and there are around 150 rows filled, it takes forever until the operation is completed.
Thats why I start to play around with the lockControllers method to avoid screen updating, but what I achieved is not enough.
Now, I can supress the update of filling in data into the rows, but still the diagram graph is being updated while the document is feeded with data. So there is no gain in speed of the overall operation.
What I want is that not only the screen updating while data feeding into the rows is suppressed, but also the diagram update. So that finally there is no update until all data is transferred into the document.

I give a code snippet here that works for the part described. If someone can give me advice, I would be grateful.

Code: Select all

Reference < XComponentLoader > xComponentLoader( xMultiComponentFactoryServer->createInstanceWithContext( 
            OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop" ) ),
            xComponentContext ), UNO_QUERY );
	
	/* Loads a component specified by an URL into the specified new or existing
	frame.
	*/
	OUString sAbsoluteDocUrl, sWorkingDir, sDocPathUrl, sArgDocUrl;
	rtl_getAppCommandArg(0, &sArgDocUrl.pData);

	osl_getProcessWorkingDir(&sWorkingDir.pData);
	osl::FileBase::getFileURLFromSystemPath( sArgDocUrl, sDocPathUrl);
	osl::FileBase::getAbsoluteFileURL( sWorkingDir, sDocPathUrl, sAbsoluteDocUrl);
    
	Reference< XComponent > xComponent = xComponentLoader->loadComponentFromURL( sAbsoluteDocUrl, OUString( RTL_CONSTASCII_USTRINGPARAM("_blank") ), 0, Sequence < ::com::sun::star::beans::PropertyValue >() );

	Reference< XController > xController( xComponent, UNO_QUERY );

        //.... some other code ....

	Reference< XModel > xModel( xComponent, UNO_QUERY );

        if( xModel.is() ) {
				xModel->lockControllers();
				printf("locking Controllers\n");
	}
	else printf("FAILED: locking Controllers\n");

best regards
Gaivota
Last edited by Gaivota on Thu Dec 25, 2014 7:38 pm, edited 1 time in total.
ApacheOpenOffice 4.0.1
Linux Debian Wheezy
FJCC
Moderator
Posts: 9277
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: [C++] lockControllers() doesn't work on xcalc diagram

Post by FJCC »

Does it help to lock the controller from the chart. I recorded the code using MRI. In Basic it gave

Code: Select all

  oSheets = ThisComponent.getSheets()
  oObj1 = oSheets.getByIndex(0)
  oCharts = oObj1.getCharts()
  
  oObj2 = oCharts.getByIndex(0)
  oEmbeddedObject = oObj2.getEmbeddedObject()
  oEmbeddedObject.lockControllers()
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Gaivota
Posts: 3
Joined: Thu Dec 25, 2014 1:09 pm

Re: [C++] lockControllers() doesn't work on xcalc diagram

Post by Gaivota »

Thanks for your quick reply.
Unfortunately I am unable to translate the basic code into C++.
When I try to handle my charts object with the getByIndex() or getEmbeddedObject() methods, it won't compile telling me that the class has no such member.
So I need some hint how to do it in C++. I can code C++ on an average level, but that UNO stuff is very complex and I haven't understand a lot yet, and try to do things mostly by trial and error... sorry and thanks for your patience..

Code: Select all

            Reference< XTableChartsSupplier > xTableChartsSupplier (xSheet, UNO_QUERY );
            Reference<XTableCharts> xtablecharts (xTableChartsSupplier->getCharts(), UNO_QUERY);
            Reference<XTableChart> xtablechart (xtablecharts, UNO_QUERY );
            any >>= xtablechart;
            Reference<XComponent> myGraph (xtablecharts->getEmbeddedObject(), UNO_QUERY);
won't compile:

error: ‘class com::sun::star::table::XTableCharts’ has no member named ‘getEmbeddedObject’
ApacheOpenOffice 4.0.1
Linux Debian Wheezy
FJCC
Moderator
Posts: 9277
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: [C++] lockControllers() doesn't work on xcalc diagram

Post by FJCC »

I know nothing about C++. If I record the same commands as I posted previously but set MRI to show C++, I get

Code: Select all

#include <com/sun/star/container/XIndexAccess.hpp>
#include <com/sun/star/document/XEmbeddedObjectSupplier.hpp>
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/sheet/XSpreadsheet.hpp>
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
#include <com/sun/star/sheet/XSpreadsheets.hpp>
#include <com/sun/star/table/XTableChart.hpp>
#include <com/sun/star/table/XTableCharts.hpp>
#include <com/sun/star/table/XTableChartsSupplier.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/uno/XInterface.hpp>

using namespace ::com::sun::star::container;
using namespace ::com::sun::star::document;
using namespace ::com::sun::star::frame;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::sheet;
using namespace ::com::sun::star::table;
using namespace ::com::sun::star::uno;
using namespace ::rtl;

void snippet(const Reference< XComponentContext > &xContext, const Reference< XInterface > &oInitialTarget)
{
    try
    {
        Reference< XSpreadsheetDocument > xSpreadsheetDocument(oInitialTarget, UNO_QUERY);
        Reference< XSpreadsheets > xSpreadsheets = xSpreadsheetDocument->getSheets();
        
        Reference< XIndexAccess > xIndexAccess(xSpreadsheets, UNO_QUERY);
        Reference< XSpreadsheet > xSpreadsheet(xIndexAccess->getByIndex(0), UNO_QUERY);
        Reference< XTableChartsSupplier > xTableChartsSupplier(xSpreadsheet, UNO_QUERY);
        Reference< XTableCharts > xTableCharts = xTableChartsSupplier->getCharts();
        
        Reference< XIndexAccess > xIndexAccess_2(xTableCharts, UNO_QUERY);
        Reference< XTableChart > xTableChart(xIndexAccess_2->getByIndex(0), UNO_QUERY);
        Reference< XEmbeddedObjectSupplier > xEmbeddedObjectSupplier(xTableChart, UNO_QUERY);
        
        Reference< XComponent > xComponent = xEmbeddedObjectSupplier->getEmbeddedObject();
        
        Reference< XModel > xModel(xComponent, UNO_QUERY);
        
        xModel->lockControllers();
        
    }
    catch (WrappedTargetException &e)
    {
        // getByIndex
        //printf(OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US).getStr());
    }
    catch (IndexOutOfBoundsException &e)
    {
        // getByIndex
        //printf(OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US).getStr());
    }
}
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Gaivota
Posts: 3
Joined: Thu Dec 25, 2014 1:09 pm

Re: [C++] lockControllers() doesn't work on xcalc diagram

Post by Gaivota »

THAT DID IT! I got the things that were missing! Thanks a lot for your quick help, I really appreciate it!
best,
Gaivota
ApacheOpenOffice 4.0.1
Linux Debian Wheezy
Post Reply