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 INCLUDED_SFX2_DOCFAC_HXX
20 #define INCLUDED_SFX2_DOCFAC_HXX
22 #include <sal/config.h>
23 #include <sfx2/dllapi.h>
24 #include <sal/types.h>
26 #include <rtl/ustring.hxx>
27 #include <sfx2/shell.hxx>
32 struct SfxObjectFactory_Impl
;
33 class SfxFilterContainer
;
37 typedef void (*SfxVoidFunc
)();
40 class SFX2_DLLPUBLIC SfxObjectFactory
43 const OUString m_sFactoryName
;
44 std::unique_ptr
<SfxObjectFactory_Impl
> pImpl
; // Additional Data
47 SfxObjectFactory( const SvGlobalName
&rName
, const OUString
& sFactoryName
);
50 const SvGlobalName
& GetClassId() const;
51 OUString
GetFactoryURL() const; // shortcut for "private:factory/GetShortName()"
52 const OUString
& GetFactoryName() const { return m_sFactoryName
; }
53 OUString
GetModuleName() const;
54 SfxFilterContainer
*GetFilterContainer() const;
57 void RegisterViewFactory(SfxViewFactory
&rFactory
);
58 sal_uInt16
GetViewFactoryCount() const;
59 SfxViewFactory
& GetViewFactory(sal_uInt16 i
= 0) const;
61 /// returns the view factory whose GetAPIViewName or GetLegacyViewName delivers the requested logical name
62 SfxViewFactory
* GetViewFactoryByViewName( const OUString
& i_rViewName
) const;
65 std::shared_ptr
<const SfxFilter
> GetTemplateFilter() const;
66 static OUString
GetStandardTemplate( const OUString
& rServiceName
);
67 static void SetStandardTemplate( const OUString
& rServiceName
, const OUString
& rTemplateName
);
68 static void SetSystemTemplate( const OUString
& rServiceName
, const OUString
& rTemplateName
);
70 void SetDocumentServiceName( const OUString
& rServiceName
);
71 const OUString
& GetDocumentServiceName() const;
73 SfxModule
* GetModule() const;
75 SAL_DLLPRIVATE
void SetModule_Impl( SfxModule
* );
76 SAL_DLLPRIVATE sal_uInt16
GetViewNo_Impl( const SfxInterfaceId i_nViewId
, const sal_uInt16 i_nFallback
) const;
79 SfxObjectFactory(const SfxObjectFactory
&) = delete;
80 const SfxObjectFactory
& operator=(const SfxObjectFactory
&) = delete;
83 #define SFX_DECL_OBJECTFACTORY() \
85 static SfxObjectFactory& Factory(); \
86 virtual SfxObjectFactory& GetFactory() const override { return Factory(); }
88 #define SFX_IMPL_OBJECTFACTORY(ClassName,GlobName,ShortName) \
89 SfxObjectFactory& ClassName::Factory() \
91 static SfxObjectFactory aObjectFactory(GlobName, ShortName); \
92 return aObjectFactory; \
94 #endif // INCLUDED_SFX2_DOCFAC_HXX
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */