Hi,

starting a new thread for a new subject, is always a good practice...

Hardie82 escribió:
Hi. I have a problem with updating my toc. I have a template-file which i
fill with chapters. In this template there is a toc included. Now after
filling the document i want to update the toc. Therefore i tried following
code:

192     private void refreshIndex() throws Exception
193     {
194             XMultiServiceFactory xMSF =
(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class,
this.ooDoc);
195             Object oContentIndex =
xMSF.createInstance("com.sun.star.text.ContentIndex");
196             XDocumentIndex xDocIndex =
(XDocumentIndex)UnoRuntime.queryInterface(XDocumentIndex.class,
oContentIndex);
197             xDocIndex.update();
198     }

well, here you are *NOT* accessing an existing document index; you are creating a *new* content index and trying to update it, *without* inserting it *first* on the document, so you get an exception.

I got the following Exception:

Exception in thread "main" com.sun.star.uno.RuntimeException: at
com.sun.star.lib.uno.environments.remote.Job.remoteUnoRequestRaisedException(Job.java:187)
        at com.sun.star.lib.uno.environments.remote.Job.execute(Job.java:153)
        at
com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:349)
        at
com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:318)
        at
com.sun.star.lib.uno.environments.remote.JavaThreadPool.enter(JavaThreadPool.java:106)
        at
com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge.sendRequest(java_remote_bridge.java:657)
        at
com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.request(ProxyFactory.java:159)
        at
com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.invoke(ProxyFactory.java:141)
        at $Proxy30.update(Unknown Source)
        at org.saxsys.excelchecker.DOCWriter.refreshIndex(DOCWriter.java:197)
        at org.saxsys.excelchecker.DOCWriter.createDocument(DOCWriter.java:93)
        at org.saxsys.excelchecker.Main.<init>(Main.java:93)
        at org.saxsys.excelchecker.Main.main(Main.java:23)

What's the problem with it?

the problem is with your code. XDocumentIndex::update throws you an exception because you try to update a new index that is not inserted in the doc.:

void SwXDocumentIndex::update(void) throw( uno::RuntimeException )
{
        vos::OGuard aGuard(Application::GetSolarMutex());
        SwSectionFmt *pFmt = GetFmt();
        SwTOXBase* pTOXBase = pFmt ? (SwTOXBaseSection*)pFmt->GetSection() : 0;
        if(!pTOXBase)
                throw uno::RuntimeException();
        ((SwTOXBaseSection*)pTOXBase)->Update();
        // Seitennummern eintragen
        ((SwTOXBaseSection*)pTOXBase)->UpdatePageNum();
}

in your case, pFmt is NULL.

If you want to update an existing content index, you must *access* it, not *create* a new one. And if you want to update a new index, you must FIRST insert it in the document.


Regards
Ariel.

--
Ariel Constenla-Haile
La Plata, Argentina

[EMAIL PROTECTED]
http://www.ArielConstenlaHaile.com.ar/ooo/



"Aus der Kriegsschule des Lebens
                - Was mich nicht umbringt,
        macht mich härter."
                Nietzsche Götzendämmerung, Sprüche und Pfeile, 8.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to