Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef _SFXDOCTEMPL_HXX
20 : #define _SFXDOCTEMPL_HXX
21 :
22 : #include "sal/config.h"
23 : #include "sfx2/dllapi.h"
24 : #include "sal/types.h"
25 : #include <tools/ref.hxx>
26 : #include <tools/string.hxx>
27 :
28 : // CLASS -----------------------------------------------------------------
29 :
30 : class SfxObjectShell;
31 :
32 : #ifndef SFX_DECL_OBJECTSHELL_DEFINED
33 : #define SFX_DECL_OBJECTSHELL_DEFINED
34 : SV_DECL_REF(SfxObjectShell)
35 : #endif
36 :
37 : class SfxDocTemplate_Impl;
38 :
39 : #ifndef SFX_DECL_DOCTEMPLATES_DEFINED
40 : #define SFX_DECL_DOCTEMPLATES_DEFINED
41 46 : SV_DECL_REF(SfxDocTemplate_Impl)
42 : #endif
43 :
44 : // class SfxDocumentTemplates --------------------------------------------
45 :
46 : class SFX2_DLLPUBLIC SfxDocumentTemplates
47 : {
48 : private:
49 : SfxDocTemplate_ImplRef pImp;
50 :
51 : SAL_DLLPRIVATE sal_Bool CopyOrMove( sal_uInt16 nTargetRegion, sal_uInt16 nTargetIdx,
52 : sal_uInt16 nSourceRegion, sal_uInt16 nSourceIdx, sal_Bool bMove );
53 : public:
54 : SfxDocumentTemplates();
55 : SfxDocumentTemplates(const SfxDocumentTemplates &);
56 : ~SfxDocumentTemplates();
57 :
58 : sal_Bool IsConstructed() { return pImp != NULL; }
59 : void Construct();
60 :
61 : const SfxDocumentTemplates &operator=(const SfxDocumentTemplates &);
62 :
63 : void ReInitFromComponent();
64 :
65 : sal_uInt16 GetRegionCount() const;
66 : const String& GetRegionName(sal_uInt16 nIdx) const; //dv!
67 : String GetFullRegionName(sal_uInt16 nIdx) const;
68 :
69 : sal_uInt16 GetCount(sal_uInt16 nRegion) const;
70 : const String& GetName(sal_uInt16 nRegion, sal_uInt16 nIdx) const; //dv!
71 : String GetPath(sal_uInt16 nRegion, sal_uInt16 nIdx) const;
72 :
73 : // Allows to retrieve the target template URL from the UCB
74 : OUString GetTemplateTargetURLFromComponent( const OUString& aGroupName,
75 : const OUString& aTitle );
76 :
77 : // Convert a resource string - a template name - to its localised pair
78 : // if it exists in templatelocnames.src
79 : static OUString ConvertResourceString(int nSourceResIds,
80 : int nDestResIds,
81 : int nCount,
82 : const OUString& rString);
83 :
84 : sal_Bool Copy(sal_uInt16 nTargetRegion,
85 : sal_uInt16 nTargetIdx,
86 : sal_uInt16 nSourceRegion,
87 : sal_uInt16 nSourceIdx);
88 : sal_Bool Move(sal_uInt16 nTargetRegion,
89 : sal_uInt16 nTargetIdx,
90 : sal_uInt16 nSourceRegion,
91 : sal_uInt16 nSourceIdx);
92 : sal_Bool Delete(sal_uInt16 nRegion, sal_uInt16 nIdx);
93 : sal_Bool InsertDir(const String &rText, sal_uInt16 nRegion);
94 :
95 : sal_Bool InsertTemplate (sal_uInt16 nSourceRegion, sal_uInt16 nIdx, const OUString &rName, const OUString &rPath);
96 :
97 : /** Change the name of an entry or a directory
98 :
99 : \param rName
100 : The new name to set
101 : \param nRegion
102 : The id of the region to rename or containing the template to rename
103 : \param nIdx
104 : The id of the template to rename or USHRT_MAX to rename the region.
105 :
106 : \return
107 : sal_True if the action could be performed, sal_False otherwise
108 :
109 : */
110 : sal_Bool SetName(const OUString &rName, sal_uInt16 nRegion, sal_uInt16 nIdx);
111 :
112 : sal_Bool CopyTo(sal_uInt16 nRegion, sal_uInt16 nIdx, const String &rName) const;
113 : sal_Bool CopyFrom(sal_uInt16 nRegion, sal_uInt16 nIdx, String &rName);
114 :
115 : sal_Bool GetFull( const String& rRegion, const String& rName, String& rPath );
116 : sal_Bool GetLogicNames( const String& rPath, String& rRegion, String& rName ) const;
117 :
118 : /** updates the configuration where the document templates structure is stored.
119 :
120 : <p>The info about the document templates (which files, which groups etc.) is stored in the
121 : configuration. This means that just by copying files into OOo's template directories, this
122 : change is not reflected in the SfxDocumentTemplates - 'cause the configuration is not synchronous with
123 : the file system. This can be enforced with this method.</p>
124 :
125 : @param _bSmart
126 : The update of the configuration is rather expensive - nothing you want to do regulary if you don't really
127 : need it. So you have the possibility to do a smart update - it first checks if the update if necessary.
128 : In case the update is needed, the additional check made it somewhat more expensive. In case it's not
129 : necessary (which should be the usual case), the check alone is (much) less expensive than the real update.
130 : <br/>
131 : So set <arg>_bSmart</arg> to <TRUE/> to do a check for necessity first.
132 : */
133 : void Update( sal_Bool _bSmart = sal_True );
134 : };
135 :
136 : #endif // #ifndef _SFXDOCTEMPL_HXX
137 :
138 :
139 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|