xref: /trunk/main/sfx2/inc/sfx2/doctempl.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _SFXDOCTEMPL_HXX
28 #define _SFXDOCTEMPL_HXX
29 
30 #include "sal/config.h"
31 #include "sfx2/dllapi.h"
32 #include "sal/types.h"
33 #include <tools/ref.hxx>
34 #include <tools/string.hxx>
35 
36 // CLASS -----------------------------------------------------------------
37 
38 class SfxObjectShell;
39 
40 #ifndef SFX_DECL_OBJECTSHELL_DEFINED
41 #define SFX_DECL_OBJECTSHELL_DEFINED
42 SV_DECL_REF(SfxObjectShell)
43 #endif
44 
45 class SfxDocTemplate_Impl;
46 
47 #ifndef SFX_DECL_DOCTEMPLATES_DEFINED
48 #define SFX_DECL_DOCTEMPLATES_DEFINED
49 SV_DECL_REF(SfxDocTemplate_Impl)
50 #endif
51 
52 // class SfxDocumentTemplates --------------------------------------------
53 
54 class SFX2_DLLPUBLIC SfxDocumentTemplates
55 {
56 private:
57 	SfxDocTemplate_ImplRef	pImp;
58 
59 	SAL_DLLPRIVATE sal_Bool CopyOrMove( sal_uInt16 nTargetRegion, sal_uInt16 nTargetIdx,
60 									sal_uInt16 nSourceRegion, sal_uInt16 nSourceIdx, sal_Bool bMove );
61 public:
62 						SfxDocumentTemplates();
63 						SfxDocumentTemplates(const SfxDocumentTemplates &);
64 						~SfxDocumentTemplates();
65 
66 	sal_Bool				IsConstructed() { return pImp != NULL; }
67 	void				Construct();
68 
69 	static sal_Bool			SaveDir( /*SfxTemplateDir &rEntry */ ) ;
70 	const SfxDocumentTemplates &operator=(const SfxDocumentTemplates &);
71 
72 	sal_Bool				Rescan( );		// Aktualisieren
73     void                ReInitFromComponent();
74 
75 	sal_Bool                IsRegionLoaded( sal_uInt16 nIdx ) const;
76 	sal_uInt16				GetRegionCount() const;
77 	const String&		GetRegionName(sal_uInt16 nIdx) const;					//dv!
78 	String 				GetFullRegionName(sal_uInt16 nIdx) const;
79 	sal_uInt16				GetRegionNo( const String &rRegionName ) const;
80 
81 	sal_uInt16				GetCount(sal_uInt16 nRegion) const;
82 	sal_uInt16				GetCount( const String &rName) const;
83 	const String&		GetName(sal_uInt16 nRegion, sal_uInt16 nIdx) const;			//dv!
84 	String				GetFileName(sal_uInt16 nRegion, sal_uInt16 nIdx) const;
85 	String				GetPath(sal_uInt16 nRegion, sal_uInt16 nIdx) const;
86 
87 	String				GetDefaultTemplatePath(const String &rLongName);
88 
89 	// Pfad zur Vorlage geben lassen; logischer Name muss angegeben
90 	// werden, damit beim Ueberschreiben einer Vorlage der
91 	// richtige Dateiname gefunden werden kann
92 	String				GetTemplatePath(sal_uInt16 nRegion, const String &rLongName) const;
93 
94 	// Allows to retrieve the target template URL from the UCB
95 	::rtl::OUString		GetTemplateTargetURLFromComponent( const ::rtl::OUString& aGroupName,
96 														 const ::rtl::OUString& aTitle );
97 
98 	// Speichern als Vorlage hat geklappt -> Aktualisieren
99 	void			NewTemplate(sal_uInt16 nRegion,
100 								const String &rLongName,
101 								const String &rFileName);
102 
103 	sal_Bool			Copy(sal_uInt16 nTargetRegion,
104 						 sal_uInt16 nTargetIdx,
105 						 sal_uInt16 nSourceRegion,
106 						 sal_uInt16 nSourceIdx);
107 	sal_Bool			Move(sal_uInt16 nTargetRegion,
108 						 sal_uInt16 nTargetIdx,
109 						 sal_uInt16 nSourceRegion,
110 						 sal_uInt16 nSourceIdx);
111 	sal_Bool			Delete(sal_uInt16 nRegion, sal_uInt16 nIdx);
112 	sal_Bool			InsertDir(const String &rText, sal_uInt16 nRegion);
113 	sal_Bool			SetName(const String &rName, sal_uInt16 nRegion, sal_uInt16 nIdx);
114 
115 	sal_Bool			CopyTo(sal_uInt16 nRegion, sal_uInt16 nIdx, const String &rName) const;
116 	sal_Bool			CopyFrom(sal_uInt16 nRegion, sal_uInt16 nIdx, String &rName);
117 
118 	SfxObjectShellRef CreateObjectShell(sal_uInt16 nRegion, sal_uInt16 nIdx);
119 	sal_Bool 			DeleteObjectShell(sal_uInt16, sal_uInt16);
120 
121 	sal_Bool 			GetFull( const String& rRegion, const String& rName, String& rPath );
122 	sal_Bool 			GetLogicNames( const String& rPath, String& rRegion, String& rName ) const;
123 
124 	/** updates the configuration where the document templates structure is stored.
125 
126 		<p>The info about the document templates (which files, which groups etc.) is stored in the
127 		configuration. This means that just by copying files into OOo's template directories, this
128 		change is not reflected in the SfxDocumentTemplates - 'cause the configuration is not synchronous with
129 		the file system. This can be enforced with this method.</p>
130 
131 	@param _bSmart
132 		The update of the configuration is rather expensive - nothing you want to do regulary if you don't really
133 		need it. So you have the possibility to do a smart update - it first checks if the update if necessary.
134 		In case the update is needed, the additional check made it somewhat more expensive. In case it's not
135 		necessary (which should be the usual case), the check alone is (much) less expensive than the real update.
136 		<br/>
137 		So set <arg>_bSmart</arg> to <TRUE/> to do a check for necessity first.
138 	*/
139 	void			Update( sal_Bool _bSmart = sal_True );
140 
141 	// allows to detect whether it is allowed to delete ( at least partially )
142 	// a group or a template, or to edit a template
143 	sal_Bool		HasUserContents( sal_uInt16 nRegion, sal_uInt16 nIdx ) const;
144 };
145 
146 #endif // #ifndef _SFXDOCTEMPL_HXX
147 
148 
149