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 
24 #ifndef INCLUDED_SVTOOLS_MODULEOPTIONS_HXX
25 #define INCLUDED_SVTOOLS_MODULEOPTIONS_HXX
26 
27 //_________________________________________________________________________________________________________________
28 //	includes
29 //_________________________________________________________________________________________________________________
30 
31 #include "unotools/unotoolsdllapi.h"
32 #include <salhelper/singletonref.hxx>
33 #include <com/sun/star/frame/XModel.hpp>
34 #include <com/sun/star/uno/Sequence.hxx>
35 #include <rtl/ustring.hxx>
36 #include <sal/types.h>
37 #include <osl/mutex.hxx>
38 #include <unotools/options.hxx>
39 
40 //_________________________________________________________________________________________________________________
41 //	const
42 //_________________________________________________________________________________________________________________
43 
44 #define FEATUREFLAG_BASICIDE                0x00000020
45 #define FEATUREFLAG_MATH           			0x00000100
46 #define FEATUREFLAG_CHART          			0x00000200
47 #define FEATUREFLAG_CALC           			0x00000800
48 #define FEATUREFLAG_DRAW           			0x00001000
49 #define FEATUREFLAG_WRITER     				0x00002000
50 #define FEATUREFLAG_IMPRESS     			0x00008000
51 #define FEATUREFLAG_INSIGHT     			0x00010000
52 
53 //_________________________________________________________________________________________________________________
54 //	forward declarations
55 //_________________________________________________________________________________________________________________
56 
57 /*-************************************************************************************************************//**
58 	@short			forward declaration to our private date container implementation
59 	@descr			We use these class as internal member to support small memory requirements.
60 					You can create the container if it is neccessary. The class which use these mechanism
61 					is faster and smaller then a complete implementation!
62 *//*-*************************************************************************************************************/
63 class SvtModuleOptions_Impl;
64 
65 //_________________________________________________________________________________________________________________
66 //	declarations
67 //_________________________________________________________________________________________________________________
68 
69 /*-************************************************************************************************************//**
70 	@short			collect informations about installation state of modules
71     @descr          Use these class to get installation state of different office modules like writer, calc etc
72                     Further you can ask for additional informations; e.g. name of standard template file, which
73                     should be used by corresponding module; or short/long name of these module factory.
74 
75 	@implements		-
76 	@base			-
77 
78 	@devstatus		ready to use
79     @threadsafe     yes
80 *//*-*************************************************************************************************************/
81 class UNOTOOLS_DLLPUBLIC SvtModuleOptions: public utl::detail::Options
82 {
83 	//-------------------------------------------------------------------------------------------------------------
84     //  public const declarations!
85 	//-------------------------------------------------------------------------------------------------------------
86     public:
87 
88         enum EModule
89         {
90             E_SWRITER       = 0,
91             E_SCALC         = 1,
92             E_SDRAW         = 2,
93             E_SIMPRESS      = 3,
94             E_SMATH         = 4,
95             E_SCHART        = 5,
96             E_SSTARTMODULE  = 6,
97             E_SBASIC        = 7,
98             E_SDATABASE     = 8,
99             E_SWEB          = 9,
100             E_SGLOBAL       = 10
101         };
102 
103         /*ATTENTION:
104             If you change these enum ... don't forget to change reading/writing and order of configuration values too!
105             See "SvtModuleOptions_Impl::impl_GetSetNames()" and his ctor for further informations.
106          */
107         enum EFactory
108         {
109             E_UNKNOWN_FACTORY = -1,
110             E_WRITER        =  0,
111             E_WRITERWEB     =  1,
112             E_WRITERGLOBAL  =  2,
113             E_CALC          =  3,
114             E_DRAW          =  4,
115             E_IMPRESS       =  5,
116             E_MATH          =  6,
117             E_CHART         =  7,
118             E_STARTMODULE   =  8,
119 			E_DATABASE		=  9,
120             E_BASIC         = 10
121 
122         };
123 
124 	//-------------------------------------------------------------------------------------------------------------
125 	//	public methods
126 	//-------------------------------------------------------------------------------------------------------------
127 	public:
128 
129 		//---------------------------------------------------------------------------------------------------------
130 		//	constructor / destructor
131 		//---------------------------------------------------------------------------------------------------------
132          SvtModuleOptions();
133         virtual ~SvtModuleOptions();
134 
135 		//---------------------------------------------------------------------------------------------------------
136 		//	interface
137 		//---------------------------------------------------------------------------------------------------------
138         sal_Bool        IsModuleInstalled         (       EModule          eModule    ) const;
139         ::rtl::OUString GetModuleName             (       EModule          eModule    ) const;
140         ::rtl::OUString GetModuleName             (       EFactory         eFactory   ) const;
141         ::rtl::OUString GetFactoryName            (       EFactory         eFactory   ) const;
142         ::rtl::OUString GetFactoryShortName       (       EFactory         eFactory   ) const;
143         ::rtl::OUString GetFactoryStandardTemplate(       EFactory         eFactory   ) const;
144         ::rtl::OUString GetFactoryWindowAttributes(       EFactory         eFactory   ) const;
145         ::rtl::OUString GetFactoryEmptyDocumentURL(       EFactory         eFactory   ) const;
146         ::rtl::OUString GetFactoryDefaultFilter   (       EFactory         eFactory   ) const;
147         sal_Bool        IsDefaultFilterReadonly   (       EFactory         eFactory   ) const;
148         sal_Int32       GetFactoryIcon            (       EFactory         eFactory   ) const;
149         static sal_Bool ClassifyFactoryByName     ( const ::rtl::OUString& sName      ,
150                                                           EFactory&        eFactory   );
151         void            SetFactoryStandardTemplate(       EFactory         eFactory   ,
152                                                     const ::rtl::OUString& sTemplate  );
153         void            SetFactoryWindowAttributes(       EFactory         eFactory   ,
154                                                     const ::rtl::OUString& sAttributes);
155         void            SetFactoryDefaultFilter   (       EFactory         eFactory   ,
156                                                     const ::rtl::OUString& sFilter    );
157 
158         //_______________________________________
159 
160         /** @short  return the corresponding application ID for the given
161                     document service name.
162          */
163         static EFactory ClassifyFactoryByServiceName(const ::rtl::OUString& sName);
164 
165         //_______________________________________
166 
167         /** @short  return the corresponding application ID for the given
168                     short name.
169          */
170         static EFactory ClassifyFactoryByShortName(const ::rtl::OUString& sName);
171 
172         //_______________________________________
173 
174         /** @short  return the corresponding application ID for the given properties.
175 
176             @descr  Because this search base on filters currently (till we have a better solution)
177                     a result is not guaranteed everytimes. May a filter does not exists for the specified
178                     content (but a FrameLoader which is not bound to any application!) ... or
179                     the given properties describe a stream (and we make no deep detection inside here!).
180 
181             @attention  The module BASIC cant be detected here. Because it does not
182                         has an own URL schema.
183 
184             @param  sURL
185                     the complete URL!
186 
187             @param  lMediaDescriptor
188                     additional informations
189 
190             @return A suitable enum value. See EFactory above.
191          */
192         static EFactory ClassifyFactoryByURL(const ::rtl::OUString&                                                           sURL            ,
193                                              const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& lMediaDescriptor);
194 
195         //_______________________________________
196 
197         /** @short  return the corresponding application ID for the given properties.
198 
199             @descr  Here we try to use the list of supported service names of the given model
200                     to find out the right application module.
201 
202             @attention  The module BASIC cant be detected here. Because it does not
203                         support any model/ctrl/view paradigm.
204 
205             @param  xModel
206                     the document model
207 
208             @return A suitable enum value. See EFactory above.
209          */
210         static EFactory ClassifyFactoryByModel(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel);
211 
212 		::rtl::OUString GetDefaultModuleName();
213 
214 		//---------------------------------------------------------------------------------------------------------
215         //  old interface ...
216 		//---------------------------------------------------------------------------------------------------------
217         sal_Bool   IsMath     () const;
218         sal_Bool   IsChart    () const;
219         sal_Bool   IsCalc     () const;
220         sal_Bool   IsDraw     () const;
221         sal_Bool   IsWriter   () const;
222         sal_Bool   IsImpress  () const;
223         sal_Bool   IsBasicIDE () const;
224 		sal_Bool   IsDataBase () const;
225 		sal_uInt32 GetFeatures() const;
226 
227 	    ::com::sun::star::uno::Sequence < ::rtl::OUString > GetAllServiceNames();
228 
229 	//-------------------------------------------------------------------------------------------------------------
230 	//	private methods
231 	//-------------------------------------------------------------------------------------------------------------
232     private:
233         UNOTOOLS_DLLPRIVATE static ::osl::Mutex& impl_GetOwnStaticMutex();
234 
235 	//-------------------------------------------------------------------------------------------------------------
236 	//	private member
237 	//-------------------------------------------------------------------------------------------------------------
238 	private:
239 
240 		/*Attention
241 
242 			Don't initialize these static member in these header!
243             a) Double defined symbols will be detected ...
244 			b) and unresolved externals exist at linking time.
245 			Do it in your source only.
246 		 */
247 
248     	static SvtModuleOptions_Impl*	m_pDataContainer	;	/// impl. data container as dynamic pointer for smaller memory requirements!
249 		static sal_Int32				m_nRefCount			;	/// internal ref count mechanism
250 
251 };		// class SvtModuleOptions
252 
253 #endif	// #ifndef INCLUDED_SVTOOLS_MODULEOPTIONS_HXX
254