Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / svtools / templatefoldercache.hxx
blob842f19111b99051b0da7c255e3f1398bbe8a6530
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 <sal/types.h>
25 #include <memory>
28 namespace svt
32 //= TemplateFolderCache
34 class TemplateFolderCacheImpl;
35 /** allows to cache the state of the template directories of OOo
36 <p>Usually, this class is used together with an instance of a the
37 <service scope="com.sun.star.frame">DocumentTemplates</service> service. It allows to scan the template folders
38 of the Office, and updates the configuration so that it reflects the most recent state of the folders.<br/>
39 As this is an expensive, the TemplateFolderCache has been introduced. It caches the state of the template
40 folders, and allows to determine if the DocumentTemplates service needs to be invoked to do the (much more expensive)
41 update.</p>
42 @example C++
43 <listing>
44 TemplateFolderCache aTemplateFolders;
45 if ( aTemplateFolders.needsUpdate() )
47 // store the current state
48 aCache.storeState();
50 // create the DocumentTemplates instance
51 Reference< XDocumentTemplates > xTemplates = ...;
53 // update the templates configuration
54 xTemplates->update();
57 // do anything which relies on a up-to-date template configuration
58 </listing>
60 class SVT_DLLPUBLIC TemplateFolderCache
62 private:
63 std::unique_ptr<TemplateFolderCacheImpl> m_pImpl;
65 public:
66 /** ctor.
67 @param _bAutoStoreState
68 Set this to <TRUE/> if you want the instance to automatically store the state of the template folders upon
69 destruction.<br/>
70 If set to <FALSE/>, you would explicitly need to call <method>storeState</method> to do this.<br/>
71 If the current state is not known (e.g. because you did not call needsUpdate, which retrieves it),
72 it is not retrieved in the dtor, regardless of the <arg>_bAutoStoreState</arg> flag.
74 TemplateFolderCache( bool _bAutoStoreState = false );
75 ~TemplateFolderCache( );
77 /** determines whether or not the template configuration needs to be updated
78 @return
79 <TRUE/> if the template configuration needs to be updated
81 bool needsUpdate();
83 /** stores the current state of the template folders in the cache */
84 void storeState();
88 } // namespace svt
91 #endif // INCLUDED_SVTOOLS_TEMPLATEFOLDERCACHE_HXX
93 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */