bump product version to 6.3.0.0.beta1
[LibreOffice.git] / include / svtools / templatefoldercache.hxx
blob2bcba8e7ec65dfc0c033ea51763df61886a54d5d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SVTOOLS_TEMPLATEFOLDERCACHE_HXX
21 #define INCLUDED_SVTOOLS_TEMPLATEFOLDERCACHE_HXX
23 #include <svtools/svtdllapi.h>
24 #include <o3tl/deleter.hxx>
25 #include <memory>
27 namespace svt
31 //= TemplateFolderCache
33 class TemplateFolderCacheImpl;
34 /** allows to cache the state of the template directories of OOo
35 <p>Usually, this class is used together with an instance of a the
36 <service scope="com.sun.star.frame">DocumentTemplates</service> service. It allows to scan the template folders
37 of the Office, and updates the configuration so that it reflects the most recent state of the folders.<br/>
38 As this is an expensive, the TemplateFolderCache has been introduced. It caches the state of the template
39 folders, and allows to determine if the DocumentTemplates service needs to be invoked to do the (much more expensive)
40 update.</p>
41 @example C++
42 <listing>
43 TemplateFolderCache aTemplateFolders;
44 if ( aTemplateFolders.needsUpdate() )
46 // store the current state
47 aCache.storeState();
49 // create the DocumentTemplates instance
50 Reference< XDocumentTemplates > xTemplates = ...;
52 // update the templates configuration
53 xTemplates->update();
56 // do anything which relies on a up-to-date template configuration
57 </listing>
59 class SVT_DLLPUBLIC TemplateFolderCache
61 private:
62 std::unique_ptr<TemplateFolderCacheImpl, o3tl::default_delete<TemplateFolderCacheImpl>> m_pImpl;
64 public:
65 /** ctor.
66 @param _bAutoStoreState
67 Set this to <TRUE/> if you want the instance to automatically store the state of the template folders upon
68 destruction.<br/>
69 If set to <FALSE/>, you would explicitly need to call <method>storeState</method> to do this.<br/>
70 If the current state is not known (e.g. because you did not call needsUpdate, which retrieves it),
71 it is not retrieved in the dtor, regardless of the <arg>_bAutoStoreState</arg> flag.
73 TemplateFolderCache( bool _bAutoStoreState = false );
74 ~TemplateFolderCache( );
76 /** determines whether or not the template configuration needs to be updated
77 @return
78 <TRUE/> if the template configuration needs to be updated
80 bool needsUpdate();
82 /** stores the current state of the template folders in the cache */
83 void storeState();
87 } // namespace svt
90 #endif // INCLUDED_SVTOOLS_TEMPLATEFOLDERCACHE_HXX
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */