1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef _SFX_OBJFAC_HXX
20 #define _SFX_OBJFAC_HXX
22 #include "sal/config.h"
23 #include "sfx2/dllapi.h"
24 #include <sal/types.h>
25 #include <tools/solar.h>
26 #include <tools/rtti.hxx>
28 // SFX_IMPL_MODULE_LIB
29 #include <osl/module.hxx>
30 #include <rtl/ustring.hxx>
32 #include <sfx2/objsh.hxx>
33 #include <sfx2/sfxdefs.hxx>
38 struct SfxObjectFactory_Impl
;
39 class SfxFilterContainer
;
42 //====================================================================
44 typedef void (*SfxVoidFunc
)();
46 #define SDT_SDT_DOCFACTPRIO 10 // Explorer
47 #define SDT_SW_DOCFACTPRIO 20 // Text Document
48 #define SDT_SWW_DOCFACTPRIO 21 // Web Document
49 #define SDT_SC_DOCFACTPRIO 30 // Table Document
50 #define SDT_SI_DOCFACTPRIO 40 // Impress Document
51 #define SDT_SD_DOCFACTPRIO 41 // Draw Document
52 #define SDT_SCH_DOCFACTPRIO 50 // Chart Document
53 #define SDT_SMA_DOCFACTPRIO 60 // Math Document
54 #define SDT_SIM_DOCFACTPRIO 70 // Image Document
55 #define SDT_FRM_DOCFACTPRIO 100 // Frame Document
56 #define SDT_MSG_DOCFACTPRIO 110 // Message Document
57 #define SDT_SDB_DOCFACTPRIO 200 // Database Document
59 //====================================================================
61 class SFX2_DLLPUBLIC SfxObjectFactory
64 const char* pShortName
;
65 SfxObjectFactory_Impl
* pImpl
; // Additional Data
66 SfxObjectShellFlags nFlags
;
67 SAL_DLLPRIVATE
void Construct();
70 SfxObjectFactory( const SvGlobalName
&rName
, SfxObjectShellFlags nFlags
, const char* pShortName
);
73 const SvGlobalName
& GetClassId() const;
74 SfxObjectShellFlags
GetFlags() { return nFlags
; }
75 const char* GetShortName() const { return pShortName
; }
76 String
GetFactoryURL() const; // shortcut for "private:factory/GetShortName()"
77 String
GetFactoryName() const { return OUString::createFromAscii(pShortName
); }
78 String
GetModuleName() const;
79 SfxFilterContainer
*GetFilterContainer( sal_Bool bForceLoad
= sal_True
) const;
82 void RegisterViewFactory(SfxViewFactory
&rFactory
);
83 sal_uInt16
GetViewFactoryCount() const;
84 SfxViewFactory
& GetViewFactory(sal_uInt16 i
= 0) const;
86 /// returns the view factory whose GetAPIViewName or GetLegacyViewName delivers the requested logical name
87 SfxViewFactory
* GetViewFactoryByViewName( const String
& i_rViewName
) const;
90 const SfxFilter
* GetTemplateFilter() const;
91 static String
GetStandardTemplate( const String
& rServiceName
);
92 static void SetStandardTemplate( const String
& rServiceName
, const String
& rTemplateName
);
93 static void SetSystemTemplate( const String
& rServiceName
, const String
& rTemplateName
);
95 void SetDocumentServiceName( const OUString
& rServiceName
);
96 const OUString
& GetDocumentServiceName() const;
98 SfxModule
* GetModule() const;
100 SAL_DLLPRIVATE
void SetModule_Impl( SfxModule
* );
101 SAL_DLLPRIVATE
static void UpdateFilterContainers_Impl();
102 SAL_DLLPRIVATE sal_uInt16
GetViewNo_Impl( const sal_uInt16 i_nViewId
, const sal_uInt16 i_nFallback
) const;
106 SAL_DLLPRIVATE
SfxObjectFactory(const SfxObjectFactory
&);
107 SAL_DLLPRIVATE
const SfxObjectFactory
& operator=(const SfxObjectFactory
&);
110 //=========================================================================
112 #define SFX_DECL_OBJECTFACTORY() \
114 static SfxObjectFactory& Factory(); \
115 virtual SfxObjectFactory& GetFactory() const { return Factory(); }
117 #define SFX_IMPL_OBJECTFACTORY(ClassName,GlobName,Flags,ShortName) \
118 SfxObjectFactory& ClassName::Factory() \
120 static SfxObjectFactory aObjectFactory(GlobName, Flags, ShortName); \
121 return aObjectFactory; \
123 #endif // #ifndef _SFX_OBJFAC_HXX
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */