Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef INCLUDED_SFX2_DOCFAC_HXX
20 : #define INCLUDED_SFX2_DOCFAC_HXX
21 :
22 : #include <sal/config.h>
23 : #include <sfx2/dllapi.h>
24 : #include <sal/types.h>
25 : #include <tools/rtti.hxx>
26 :
27 : // SFX_IMPL_MODULE_LIB
28 : #include <osl/module.hxx>
29 : #include <rtl/ustring.hxx>
30 :
31 : #include <sfx2/objsh.hxx>
32 :
33 : class SfxMedium;
34 : class SfxFilter;
35 : class SfxViewFactory;
36 : struct SfxObjectFactory_Impl;
37 : class SfxFilterContainer;
38 : class SfxBindings;
39 :
40 : typedef void (*SfxVoidFunc)();
41 :
42 :
43 : class SFX2_DLLPUBLIC SfxObjectFactory
44 : {
45 : private:
46 : const char* pShortName;
47 : SfxObjectFactory_Impl* pImpl; // Additional Data
48 : SfxObjectShellFlags nFlags;
49 : SAL_DLLPRIVATE void Construct();
50 :
51 : public:
52 : SfxObjectFactory( const SvGlobalName &rName, SfxObjectShellFlags nFlags, const char* pShortName );
53 : ~SfxObjectFactory();
54 :
55 : const SvGlobalName& GetClassId() const;
56 4119 : SfxObjectShellFlags GetFlags() { return nFlags; }
57 15156 : const char* GetShortName() const { return pShortName; }
58 : OUString GetFactoryURL() const; // shortcut for "private:factory/GetShortName()"
59 13 : OUString GetFactoryName() const { return OUString::createFromAscii(pShortName); }
60 : OUString GetModuleName() const;
61 : SfxFilterContainer *GetFilterContainer( bool bForceLoad = true) const;
62 :
63 : // Views
64 : void RegisterViewFactory(SfxViewFactory &rFactory);
65 : sal_uInt16 GetViewFactoryCount() const;
66 : SfxViewFactory& GetViewFactory(sal_uInt16 i = 0) const;
67 :
68 : /// returns the view factory whose GetAPIViewName or GetLegacyViewName delivers the requested logical name
69 : SfxViewFactory* GetViewFactoryByViewName( const OUString& i_rViewName ) const;
70 :
71 : // Filter
72 : const SfxFilter* GetTemplateFilter() const;
73 : static OUString GetStandardTemplate( const OUString& rServiceName );
74 : static void SetStandardTemplate( const OUString& rServiceName, const OUString& rTemplateName );
75 : static void SetSystemTemplate( const OUString& rServiceName, const OUString& rTemplateName );
76 :
77 : void SetDocumentServiceName( const OUString& rServiceName );
78 : const OUString& GetDocumentServiceName() const;
79 :
80 : SfxModule* GetModule() const;
81 :
82 : SAL_DLLPRIVATE void SetModule_Impl( SfxModule* );
83 : SAL_DLLPRIVATE static void UpdateFilterContainers_Impl();
84 : SAL_DLLPRIVATE sal_uInt16 GetViewNo_Impl( const sal_uInt16 i_nViewId, const sal_uInt16 i_nFallback ) const;
85 :
86 : private:
87 : SfxObjectFactory(const SfxObjectFactory&) SAL_DELETED_FUNCTION;
88 : const SfxObjectFactory& operator=(const SfxObjectFactory &) SAL_DELETED_FUNCTION;
89 : };
90 :
91 : #define SFX_DECL_OBJECTFACTORY() \
92 : public: \
93 : static SfxObjectFactory& Factory(); \
94 : virtual SfxObjectFactory& GetFactory() const SAL_OVERRIDE { return Factory(); }
95 :
96 : #define SFX_IMPL_OBJECTFACTORY(ClassName,GlobName,Flags,ShortName) \
97 : SfxObjectFactory& ClassName::Factory() \
98 : { \
99 : static SfxObjectFactory aObjectFactory(GlobName, Flags, ShortName); \
100 : return aObjectFactory; \
101 : }
102 : #endif // INCLUDED_SFX2_DOCFAC_HXX
103 :
104 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|