LibreOffice Module svtools (master) 1
C++

allows to cache the state of the template directories of OOo

allows to cache the state of the template directories of OOo

Usually, this class is used together with an instance of the <service scope="com.sun.star.frame">DocumentTemplates</service> service. It allows to scan the template folders of the Office, and updates the configuration so that it reflects the most recent state of the folders.
As this is an expensive, the TemplateFolderCache has been introduced. It caches the state of the template folders, and allows to determine if the DocumentTemplates service needs to be invoked to do the (much more expensive) update.

<listing> TemplateFolderCache aTemplateFolders; if ( aTemplateFolders.needsUpdate() ) { store the current state aCache.storeState();

create the DocumentTemplates instance Reference< XDocumentTemplates > xTemplates = ...;

update the templates configuration xTemplates->update(); }

do anything which relies on a up-to-date template configuration </listing>