xref: /aoo41x/main/sfx2/inc/sfx2/docfac.hxx (revision 353d8f4d)
1*353d8f4dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*353d8f4dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*353d8f4dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*353d8f4dSAndrew Rist  * distributed with this work for additional information
6*353d8f4dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*353d8f4dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*353d8f4dSAndrew Rist  * "License"); you may not use this file except in compliance
9*353d8f4dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*353d8f4dSAndrew Rist  *
11*353d8f4dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*353d8f4dSAndrew Rist  *
13*353d8f4dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*353d8f4dSAndrew Rist  * software distributed under the License is distributed on an
15*353d8f4dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*353d8f4dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*353d8f4dSAndrew Rist  * specific language governing permissions and limitations
18*353d8f4dSAndrew Rist  * under the License.
19*353d8f4dSAndrew Rist  *
20*353d8f4dSAndrew Rist  *************************************************************/
21*353d8f4dSAndrew Rist 
22*353d8f4dSAndrew Rist 
23cdf0e10cSrcweir #ifndef _SFX_OBJFAC_HXX
24cdf0e10cSrcweir #define _SFX_OBJFAC_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include "sal/config.h"
27cdf0e10cSrcweir #include "sfx2/dllapi.h"
28cdf0e10cSrcweir #include <sal/types.h>
29cdf0e10cSrcweir #include <tools/solar.h>
30cdf0e10cSrcweir #include <tools/rtti.hxx>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir // SFX_IMPL_MODULE_LIB
33cdf0e10cSrcweir #include <vos/module.hxx>
34cdf0e10cSrcweir #include <rtl/ustring.hxx>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir #include <sfx2/objsh.hxx>
37cdf0e10cSrcweir #include <sfx2/sfxdefs.hxx>
38cdf0e10cSrcweir 
39cdf0e10cSrcweir class SfxObjectFactoryArr_Impl;
40cdf0e10cSrcweir class SfxMedium;
41cdf0e10cSrcweir class SfxFilter;
42cdf0e10cSrcweir class SfxViewFactory;
43cdf0e10cSrcweir struct SfxObjectFactory_Impl;
44cdf0e10cSrcweir class SfxFilterContainer;
45cdf0e10cSrcweir class SfxBindings;
46cdf0e10cSrcweir 
47cdf0e10cSrcweir //====================================================================
48cdf0e10cSrcweir 
49cdf0e10cSrcweir typedef void (*SfxVoidFunc)();
50cdf0e10cSrcweir 
51cdf0e10cSrcweir #define SDT_SDT_DOCFACTPRIO     10      // Explorer
52cdf0e10cSrcweir #define SDT_SW_DOCFACTPRIO      20      // Text-Dokument
53cdf0e10cSrcweir #define SDT_SWW_DOCFACTPRIO     21    	// Web-Dokument
54cdf0e10cSrcweir #define SDT_SC_DOCFACTPRIO      30      // Tabellen-Dokument
55cdf0e10cSrcweir #define SDT_SI_DOCFACTPRIO      40      // Impress-Dokument
56cdf0e10cSrcweir #define SDT_SD_DOCFACTPRIO      41      // Draw-Dokument
57cdf0e10cSrcweir #define SDT_SCH_DOCFACTPRIO     50      // Chart-Dokument
58cdf0e10cSrcweir #define SDT_SMA_DOCFACTPRIO     60      // Math-Dokument
59cdf0e10cSrcweir #define SDT_SIM_DOCFACTPRIO     70      // Image-Dokument
60cdf0e10cSrcweir #define SDT_FRM_DOCFACTPRIO    100      // Rahmen-Dokument
61cdf0e10cSrcweir #define SDT_MSG_DOCFACTPRIO    110      // Nachrichten-Dokument
62cdf0e10cSrcweir #define SDT_SDB_DOCFACTPRIO    200      // Datenbank-Dokument
63cdf0e10cSrcweir 
64cdf0e10cSrcweir //====================================================================
65cdf0e10cSrcweir 
66cdf0e10cSrcweir class SFX2_DLLPUBLIC SfxObjectFactory
67cdf0e10cSrcweir {
68cdf0e10cSrcweir private:
69cdf0e10cSrcweir 	const char* 			pShortName;		// Objekt-Kurzname
70cdf0e10cSrcweir 	SfxObjectFactory_Impl*	pImpl;			// Zusatzdaten
71cdf0e10cSrcweir 	SfxObjectShellFlags     nFlags;
72cdf0e10cSrcweir 	SAL_DLLPRIVATE void Construct();
73cdf0e10cSrcweir 
74cdf0e10cSrcweir public:
75cdf0e10cSrcweir     SfxObjectFactory( const SvGlobalName &rName, SfxObjectShellFlags nFlags, const char* pShortName );
76cdf0e10cSrcweir 	~SfxObjectFactory();
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 	const SvGlobalName& GetClassId() const;
GetFlags()79cdf0e10cSrcweir 	SfxObjectShellFlags GetFlags() { return nFlags; }
GetShortName() const80cdf0e10cSrcweir 	const char* 	GetShortName() const { return pShortName; }
81cdf0e10cSrcweir     String          GetFactoryURL() const;  // shortcut for "private:factory/GetShortName()"
GetFactoryName() const82cdf0e10cSrcweir 	String			GetFactoryName() const { return String::CreateFromAscii( pShortName ); }
83cdf0e10cSrcweir     String          GetModuleName() const;
84cdf0e10cSrcweir 	void			SetDocumentTypeNameResource( const ResId& rId );
85cdf0e10cSrcweir 	String			GetDocumentTypeName() const;
86cdf0e10cSrcweir 	SfxFilterContainer *GetFilterContainer( sal_Bool bForceLoad = sal_True) const;
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 	// Views
89cdf0e10cSrcweir 	void			RegisterViewFactory(SfxViewFactory &rFactory);
90cdf0e10cSrcweir 	sal_uInt16			GetViewFactoryCount() const;
91cdf0e10cSrcweir 	SfxViewFactory& GetViewFactory(sal_uInt16 i = 0) const;
92cdf0e10cSrcweir 
93cdf0e10cSrcweir     /// returns the view factory whose GetAPIViewName or GetLegacyViewName delivers the requested logical name
94cdf0e10cSrcweir     SfxViewFactory* GetViewFactoryByViewName( const String& i_rViewName ) const;
95cdf0e10cSrcweir 
96cdf0e10cSrcweir 	// Filter
97cdf0e10cSrcweir 	const SfxFilter* GetTemplateFilter() const;
98cdf0e10cSrcweir 	static String	GetStandardTemplate( const String& rServiceName );
99cdf0e10cSrcweir 	static void		SetStandardTemplate( const String& rServiceName, const String& rTemplateName );
100cdf0e10cSrcweir 	static void		SetSystemTemplate( const String& rServiceName, const String& rTemplateName );
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 	void			SetDocumentServiceName( const rtl::OUString& rServiceName );
103cdf0e10cSrcweir 	const rtl::OUString&	GetDocumentServiceName() const;
104cdf0e10cSrcweir 
105cdf0e10cSrcweir 	SfxModule*      GetModule() const;
106cdf0e10cSrcweir 
107cdf0e10cSrcweir //#if 0 // _SOLAR__PRIVATE
108cdf0e10cSrcweir     SAL_DLLPRIVATE void SetModule_Impl( SfxModule* );
109cdf0e10cSrcweir 	SAL_DLLPRIVATE static void UpdateFilterContainers_Impl();
110cdf0e10cSrcweir     SAL_DLLPRIVATE sal_uInt16 GetViewNo_Impl( const sal_uInt16 i_nViewId, const sal_uInt16 i_nFallback ) const;
111cdf0e10cSrcweir //#endif
112cdf0e10cSrcweir 
113cdf0e10cSrcweir private:
114cdf0e10cSrcweir 	// Kopieren verboten
115cdf0e10cSrcweir 	SAL_DLLPRIVATE SfxObjectFactory(const SfxObjectFactory&);
116cdf0e10cSrcweir 	SAL_DLLPRIVATE const SfxObjectFactory& operator=(const SfxObjectFactory &);
117cdf0e10cSrcweir };
118cdf0e10cSrcweir 
119cdf0e10cSrcweir //=========================================================================
120cdf0e10cSrcweir 
121cdf0e10cSrcweir #define SFX_DECL_OBJECTFACTORY()                                       		\
122cdf0e10cSrcweir private:																	\
123cdf0e10cSrcweir 	static SfxObjectFactory*	pObjectFactory;								\
124cdf0e10cSrcweir public:                                                                     \
125cdf0e10cSrcweir     static SfxObjectFactory&    Factory();                                  \
126cdf0e10cSrcweir     virtual SfxObjectFactory&   GetFactory() const { return Factory(); }
127cdf0e10cSrcweir 
128cdf0e10cSrcweir #define SFX_IMPL_OBJECTFACTORY(ClassName,GlobName,Flags,ShortName)          \
129cdf0e10cSrcweir     SfxObjectFactory*           ClassName::pObjectFactory = 0;              \
130cdf0e10cSrcweir     SfxObjectFactory&           ClassName::Factory()                          \
131cdf0e10cSrcweir                                 { if (!pObjectFactory)                      \
132cdf0e10cSrcweir                                     pObjectFactory =                        \
133cdf0e10cSrcweir                                         new SfxObjectFactory( GlobName, Flags, ShortName ); \
134cdf0e10cSrcweir                                   return *pObjectFactory;                    \
135cdf0e10cSrcweir                                 }
136cdf0e10cSrcweir #endif // #ifndef _SFX_OBJFAC_HXX
137cdf0e10cSrcweir 
138