xref: /trunk/main/sfx2/inc/sfx2/doctempl.hxx (revision 353d8f4d)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _SFXDOCTEMPL_HXX
24 #define _SFXDOCTEMPL_HXX
25 
26 #include "sal/config.h"
27 #include "sfx2/dllapi.h"
28 #include "sal/types.h"
29 #include <tools/ref.hxx>
30 #include <tools/string.hxx>
31 
32 // CLASS -----------------------------------------------------------------
33 
34 class SfxObjectShell;
35 
36 #ifndef SFX_DECL_OBJECTSHELL_DEFINED
37 #define SFX_DECL_OBJECTSHELL_DEFINED
38 SV_DECL_REF(SfxObjectShell)
39 #endif
40 
41 class SfxDocTemplate_Impl;
42 
43 #ifndef SFX_DECL_DOCTEMPLATES_DEFINED
44 #define SFX_DECL_DOCTEMPLATES_DEFINED
45 SV_DECL_REF(SfxDocTemplate_Impl)
46 #endif
47 
48 // class SfxDocumentTemplates --------------------------------------------
49 
50 class SFX2_DLLPUBLIC SfxDocumentTemplates
51 {
52 private:
53 	SfxDocTemplate_ImplRef	pImp;
54 
55 	SAL_DLLPRIVATE sal_Bool CopyOrMove( sal_uInt16 nTargetRegion, sal_uInt16 nTargetIdx,
56 									sal_uInt16 nSourceRegion, sal_uInt16 nSourceIdx, sal_Bool bMove );
57 public:
58 						SfxDocumentTemplates();
59 						SfxDocumentTemplates(const SfxDocumentTemplates &);
60 						~SfxDocumentTemplates();
61 
IsConstructed()62 	sal_Bool				IsConstructed() { return pImp != NULL; }
63 	void				Construct();
64 
65 	static sal_Bool			SaveDir( /*SfxTemplateDir &rEntry */ ) ;
66 	const SfxDocumentTemplates &operator=(const SfxDocumentTemplates &);
67 
68 	sal_Bool				Rescan( );		// Aktualisieren
69     void                ReInitFromComponent();
70 
71 	sal_Bool                IsRegionLoaded( sal_uInt16 nIdx ) const;
72 	sal_uInt16				GetRegionCount() const;
73 	const String&		GetRegionName(sal_uInt16 nIdx) const;					//dv!
74 	String 				GetFullRegionName(sal_uInt16 nIdx) const;
75 	sal_uInt16				GetRegionNo( const String &rRegionName ) const;
76 
77 	sal_uInt16				GetCount(sal_uInt16 nRegion) const;
78 	sal_uInt16				GetCount( const String &rName) const;
79 	const String&		GetName(sal_uInt16 nRegion, sal_uInt16 nIdx) const;			//dv!
80 	String				GetFileName(sal_uInt16 nRegion, sal_uInt16 nIdx) const;
81 	String				GetPath(sal_uInt16 nRegion, sal_uInt16 nIdx) const;
82 
83 	String				GetDefaultTemplatePath(const String &rLongName);
84 
85 	// Pfad zur Vorlage geben lassen; logischer Name muss angegeben
86 	// werden, damit beim Ueberschreiben einer Vorlage der
87 	// richtige Dateiname gefunden werden kann
88 	String				GetTemplatePath(sal_uInt16 nRegion, const String &rLongName) const;
89 
90 	// Allows to retrieve the target template URL from the UCB
91 	::rtl::OUString		GetTemplateTargetURLFromComponent( const ::rtl::OUString& aGroupName,
92 														 const ::rtl::OUString& aTitle );
93 
94 	// Speichern als Vorlage hat geklappt -> Aktualisieren
95 	void			NewTemplate(sal_uInt16 nRegion,
96 								const String &rLongName,
97 								const String &rFileName);
98 
99 	sal_Bool			Copy(sal_uInt16 nTargetRegion,
100 						 sal_uInt16 nTargetIdx,
101 						 sal_uInt16 nSourceRegion,
102 						 sal_uInt16 nSourceIdx);
103 	sal_Bool			Move(sal_uInt16 nTargetRegion,
104 						 sal_uInt16 nTargetIdx,
105 						 sal_uInt16 nSourceRegion,
106 						 sal_uInt16 nSourceIdx);
107 	sal_Bool			Delete(sal_uInt16 nRegion, sal_uInt16 nIdx);
108 	sal_Bool			InsertDir(const String &rText, sal_uInt16 nRegion);
109 	sal_Bool			SetName(const String &rName, sal_uInt16 nRegion, sal_uInt16 nIdx);
110 
111 	sal_Bool			CopyTo(sal_uInt16 nRegion, sal_uInt16 nIdx, const String &rName) const;
112 	sal_Bool			CopyFrom(sal_uInt16 nRegion, sal_uInt16 nIdx, String &rName);
113 
114 	SfxObjectShellRef CreateObjectShell(sal_uInt16 nRegion, sal_uInt16 nIdx);
115 	sal_Bool 			DeleteObjectShell(sal_uInt16, sal_uInt16);
116 
117 	sal_Bool 			GetFull( const String& rRegion, const String& rName, String& rPath );
118 	sal_Bool 			GetLogicNames( const String& rPath, String& rRegion, String& rName ) const;
119 
120 	/** updates the configuration where the document templates structure is stored.
121 
122 		<p>The info about the document templates (which files, which groups etc.) is stored in the
123 		configuration. This means that just by copying files into OOo's template directories, this
124 		change is not reflected in the SfxDocumentTemplates - 'cause the configuration is not synchronous with
125 		the file system. This can be enforced with this method.</p>
126 
127 	@param _bSmart
128 		The update of the configuration is rather expensive - nothing you want to do regulary if you don't really
129 		need it. So you have the possibility to do a smart update - it first checks if the update if necessary.
130 		In case the update is needed, the additional check made it somewhat more expensive. In case it's not
131 		necessary (which should be the usual case), the check alone is (much) less expensive than the real update.
132 		<br/>
133 		So set <arg>_bSmart</arg> to <TRUE/> to do a check for necessity first.
134 	*/
135 	void			Update( sal_Bool _bSmart = sal_True );
136 
137 	// allows to detect whether it is allowed to delete ( at least partially )
138 	// a group or a template, or to edit a template
139 	sal_Bool		HasUserContents( sal_uInt16 nRegion, sal_uInt16 nIdx ) const;
140 };
141 
142 #endif // #ifndef _SFXDOCTEMPL_HXX
143 
144 
145